function on_message(self, message_id, message, sender)
if message_id == hash("Play") then
particlefx.play("#pfx")
elseif message_id == hash("Stop") then
print('pfx stop')
particlefx.stop("#pfx", { clear = true })
end
end
When I send the message, I get the printed string, but the pfx just keeps on particle-ing.
No errors are given. But I think it’s an addressing problem.
Run the project and press the spacebar to send the stop message. You should see ‘pfx stop’ printed from the particle script, just before the .stop call.
I don’t think you shared exactly what you were testing yourself. The project will not build in the state you shared it (there are a bunch of missing resources).
Still, I took a look and the particlefx_play.script looks like this:
function init(self)
particlefx.play(".")
end
function on_message(self, message_id, message, sender)
if message_id == hash("Play") then
particlefx.play("#explosion")
elseif message_id == hash("Stop") then
print('pfx stop')
particlefx.stop("#explosion", { clear = true })
end
end
I was not able to find a single place where a “Stop” message was sent to that script. And no “Play” message either.
Something to note is that you do a particlefx.play(".") in init() of this script. This will start playing one instance of the particlefx animation. If I then add a call to particlefx.stop("#explosion") the pfx will indeed not stop. I believe it has to do with the “.” vs “#explosion”. You should play “#explosion” and stop “#explosion”.
Hi there - @britzl is right, the line in init( ) is the problem.
Having removed the missing resources, the test project works and you can stop the animation. If you add a key for playing and the “Play” message, playing the animation works too.
function init(self)
-- particlefx.play(".")
particlefx.play("#explosion_1")
end
function on_message(self, message_id, message, sender)
if message_id == hash("Play") then
particlefx.play("#explosion_1")
elseif message_id == hash("Stop") then
print('pfx stop')
particlefx.stop("#explosion_1", { clear = true })
end
end
I think I agree with you, although I don’t know the details of the implementation so I can’t say how hard or easy it would be. Please create a ticket on GitHub for this request!