How to stop playing a sound?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
EntropySpark
Inserter
Inserter
Posts: 21
Joined: Wed Jan 31, 2018 7:06 am
Contact:

How to stop playing a sound?

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: How to stop playing a sound?

Post 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?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to stop playing a sound?

Post 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.

User avatar
EntropySpark
Inserter
Inserter
Posts: 21
Joined: Wed Jan 31, 2018 7:06 am
Contact:

Re: How to stop playing a sound?

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: How to stop playing a sound?

Post 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...:/

Post Reply

Return to “Modding help”