Page 1 of 1

How to stop playing a sound?

Posted: Fri Feb 09, 2018 8:57 am
by EntropySpark
After I start playing a sound using

Code: Select all

surface.play_sound
, how do I stop it? I'm successfully playing 'utility/default_manual_repair' for my mod, but the sound will continue after repairing stops.

Re: How to stop playing a sound?

Posted: Fri Feb 09, 2018 11:15 am
by eradicator

Code: Select all

/c game.player.surface.play_sound{path='utility/default_manual_repair',position=game.player.position}
Only plays once for me. Are you sure you're not triggering it again yourself?

Re: How to stop playing a sound?

Posted: Fri Feb 09, 2018 5:16 pm
by DaveMcW
I don't think it's possible to stop a sound in the middle of playing. The best you can do is keep your sound files short.

Re: How to stop playing a sound?

Posted: Sat Feb 10, 2018 3:44 am
by EntropySpark
eradicator wrote:

Code: Select all

/c game.player.surface.play_sound{path='utility/default_manual_repair',position=game.player.position}
Only plays once for me. Are you sure you're not triggering it again yourself?
I'm triggering it until repairing stops. The sound eventually stops, but a few seconds after the repairing stops, which isn't the case for native repairing.
DaveMcW wrote:I don't think it's possible to stop a sound in the middle of playing. The best you can do is keep your sound files short.
I'm using the native repair sound, so that's not an option here.

Re: How to stop playing a sound?

Posted: Sat Feb 10, 2018 7:09 am
by eradicator
I don't think there's a method to stop a sound either though. You might try requesting that. Or at least the ability to change to volume afterwards. I'm not sure if the old sound explosions could be stopped in the middle either...:/