Jump to content

[SOLVED] Why's "SoundEmitter:KillSound" not working?


Recommended Posts

Hello, I have a problem if somebody could help me :).

So, here's the code.

        timeline =
        {
		TimeEvent(18*FRAMES, function( inst )
		    inst.SoundEmitter:PlaySound("dontstarve/creatures/worm/death")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/werepig/howl")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/worm/distant")
            inst.SoundEmitter:PlaySound("dontstarve/creatures/werepig/grunt")
            inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/vargr/howl")
            inst.SoundEmitter:PlaySound("dontstarve_DLC001/creatures/bearger/grrrr")
            end),
			TimeEvent(78*FRAMES, function( inst )
            inst.SoundEmitter:KillSound("dontstarve/creatures/worm/death")
			inst.SoundEmitter:KillSound("dontstarve/creatures/werepig/howl")
			inst.SoundEmitter:KillSound("dontstarve/creatures/worm/distant")
			inst.SoundEmitter:KillSound("dontstarve/creatures/werepig/grunt")
			inst.SoundEmitter:KillSound("dontstarve_DLC001/creatures/vargr/howl")
			inst.SoundEmitter:KillSound("dontstarve_DLC001/creatures/bearger/grrrr")
            end),
        },

The PlaySound plays the sounds properly but when I want KillSound to mute/stop them it doesn't! Isn't KillSound supposed to mute/stop the sounds?

Edited by SuperDavid
Link to comment
Share on other sites

@SuperDavid If you look more carefully at how KillSound is used, for example in the Lavae "thawing" state...

    State{
        name = "thaw",
        tags = {"busy", "thawing"},
        
        onenter = function(inst) 
            if inst.components.locomotor then
                inst.components.locomotor:StopMoving()
            end
            inst.AnimState:PlayAnimation("frozen_loop_pst", true)
            inst.SoundEmitter:PlaySound("dontstarve/common/freezethaw", "thawing")
        end,
        
        onexit = function(inst)
            inst.SoundEmitter:KillSound("thawing")
        end,

        events =
        {   
            EventHandler("unfreeze", function(inst) inst.components.health:Kill() end),
        },
    },

PlaySound has an optional second argument for a sound "label", and you give KillSound the label.

Link to comment
Share on other sites

9 hours ago, rezecib said:

PlaySound has an optional second argument for a sound "label", and you give KillSound the label

Yes, thank you shortly after I posted this I realized that but my internet went off so I could put this as solved, but thank you for telling me too :D~!!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...