Hello.
I'm making a gamemode, and i needed a fireplace for it. Problem is that i'm using an info_particle_system for emitting effects, however i tried multiple different ways to stop the particles but it just doesn't want to.
I tried:
[lua]
fireeffect:Fire("Stop","", 0)
fireeffect:Fire("Start","", 0)
fireeffect:Remove()
self:StopParticles()
[/lua]
But none of these seem to work.
Full code:
[lua]
function ENT:Use( activator, caller )
if !self.On then
self.On = true
local fireeffect = ents.Create("info_particle_system")
fireeffect:SetPos(self.Entity:GetPos()+Vector(0,0,5))
fireeffect:SetKeyValue( "effect_name", "env_fire_small")
fireeffect:SetKeyValue( "start_active", "1")
fireeffect:SetColor(Color(255,0,0,255))
fireeffect:Spawn()
fireeffect:Activate()
fireeffect:SetParent(self.Entity)
local smokeeffect = ents.Create("info_particle_system")
smokeeffect:SetPos(self.Entity:GetPos()+Vector(0,0,15))
smokeeffect:SetKeyValue( "effect_name", "env_fire_large_smoke")
smokeeffect:SetKeyValue( "start_active", "1")
smokeeffect:SetColor(Color(255,0,0,255))
smokeeffect:Spawn()
smokeeffect:Activate()
smokeeffect:SetParent(self.Entity)
timer.Simple(60, function() self.On = false print("off") end)
end
end
[/lua]
[url]https://developer.valvesoftware.com/wiki/Info_particle_system[/url]
Why do you fire START to STOP your particles? :suicide:
[editline]22nd June 2014[/editline]
Also, if you are going to do something to those effects, you gotta save a reference to them, something like "self.smokeeffect = smokeeffect" so you can use the variable later.
[QUOTE=Robotboy655;45182658][url]https://developer.valvesoftware.com/wiki/Info_particle_system[/url]
Why do you fire START to STOP your particles? :suicide:
[/QUOTE]
Testing Purposes. I tried Stop before but it didn't work.
[QUOTE=Robotboy655;45182658]
[editline]22nd June 2014[/editline]
Also, if you are going to do something to those effects, you gotta save a reference to them, something like "self.smokeeffect = smokeeffect" so you can use the variable later.[/QUOTE]
Good idea, i'll do that.
but my problem still persists.
Your problem is that you do not know how to use local/global variables and their differences. I'd suggest you learn about those before continuing coding, all of your threads have the same mistake.
[QUOTE=Robotboy655;45182886]Your problem is that you do not know how to use local/global variables and their differences. I'd suggest you learn about those before continuing coding, all of your threads have the same mistake.[/QUOTE]
I just switched the local variables in the Use code to a global one, but it still fails to work. I've also tried using self.
[QUOTE=buu342;45185195]I just switched the local variables in the Use code to a global one, but it still fails to work. I've also tried using self.[/QUOTE]
Don't use local variables or global variables for this. You gotta use self.MyVariable for entities and sweps.
Post new code with self.* as variable name.
[QUOTE=Robotboy655;45185248]Don't use local variables or global variables for this. You gotta use self.MyVariable for entities and sweps.
Post new code with self.* as variable name.[/QUOTE]
That's exactly what i did. And it didn't work.
Console outputs off, however the particle keeps emmitting.
[lua]
function ENT:Use( activator, caller )
if !self.On then
self.On = true
self.fireeffect= ents.Create("info_particle_system")
self.fireeffect:SetPos(self.Entity:GetPos()+Vector(0,0,5))
self.fireeffect:SetKeyValue( "effect_name", "env_fire_small")
self.fireeffect:Fire("Start","", 0)
self.fireeffect:Spawn()
self.fireeffect:Activate()
self.fireeffect:SetParent(self.Entity)
self.smokeeffect = ents.Create("info_particle_system")
self.smokeeffect:SetPos(self.Entity:GetPos()+Vector(0,0,15))
self.smokeeffect:SetKeyValue( "effect_name", "env_fire_large_smoke")
self.smokeeffect:Fire("Start","", 0)
self.smokeeffect:Spawn()
self.smokeeffect:Activate()
self.smokeeffect:SetParent(self.Entity)
timer.Simple(60, function() if !IsValid(self.Entity) then return end self.On = false print("off") self.fireeffect:Fire("Stop","", 0) end)
end
end
[/lua]
Try this putting this in there:
[code]
self.fireeffect:Fire("Kill","",0.1)
[/code]
[QUOTE=vrej;45186497]Try this putting this in there:
[code]
self.fireeffect:Fire("Kill","",0.1)
[/code][/QUOTE]
No luck.
Bump
The code I gave you works for me, I don't see why it's not working for you.
[QUOTE=vrej;45200589]The code I gave you works for me, I don't see why it's not working for you.[/QUOTE]
Could it be something with the entity's code?
The entity is placed in entities/sent_fireplace.lua if that makes a difference.
[url]http://pastebin.com/reBKdQcn[/url]
[QUOTE=buu342;45203468]Could it be something with the entity's code?
The entity is placed in entities/sent_fireplace.lua if that makes a difference.
[url]http://pastebin.com/reBKdQcn[/url][/QUOTE]
Oh I see your problem, put the start and stop after the activate
[QUOTE=vrej;45203561]Oh I see your problem, put the start and stop after the activate[/QUOTE]
Ok, that didn't work, HOWEVER, when i stop the smoke effect, BOTH particles stop.
[editline]hhh[/editline]
OOHHH, env_fire_large_smoke includes both the fire AND the smoke!
[editline]hhh[/editline]
Ok well, now im using 2 different particles. Thanks for the help everyone!
Sorry, you need to Log In to post a reply to this thread.