Stopping sound [UNRESOLVABLE]

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Stopping sound [UNRESOLVABLE]

Post by Granamir »

Hi,
i'm having some problem stopping a sound.
I made an object in map play sound, unfortunatelly this sound lasts 40 seconds and i need to stop it when i change map (because i can hear it even if i changed map vertically, no matter map distance from the one playing).
I'd like to stop it instead avoid problem making new map really far from the one playing sound.
So far i tryed to destroy item playing, let him play silence, going 20 levels down (in a new map).
Anyone has a clue for me?
Ty
Last edited by Granamir on Sat Mar 14, 2015 5:14 pm, edited 3 times in total.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Stopping sound

Post by minmay »

Play your sound in a SoundComponent and use SoundComponent:stop() when you need to stop it.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Re: Stopping sound

Post by Granamir »

works perfectly.
TY
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Re: Stopping sound

Post by Granamir »

After some tests it come out it doesn't works.
Don't know why, on first try it worked perfectly. Later i tryed the whole procedure, step by step, that would lead party to play that sound and nothing happens. The i tryed to play it form console and again nothing happens, but if i play with playSound it works.
I tryed everything exept the right one.
Anyone can help me?
Ty

Code: Select all

function sottofondo()
	sound_1.sound:enable()
	sound_2.sound:enable()
	sound_1.sound:play("soundA")
	sound_2.sound:play("soundB")
end
i used 2 sound object disabling their sound component so they don't start playing form begining.
I call that function with a timer. Tryed with a print to see if it goes inside that functon and everything is fine, except i don't hear anything.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Stopping sound

Post by minmay »

Is the party on the same level as the SoundComponent? If not, then of course they won't hear the sound. If you want a sound to persistently follow the party, adding SoundComponents to the party object will probably work.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Re: Stopping sound

Post by Granamir »

k i think i got it
seems if party is disabled sound played by sound object can't be heard
and for some reason when i started that level with party already disbled i wasn't able to hear sound anymore, even if i enabled party later on
...so is there a way to hear sounds even if party is disabled? or a way to stop playSound?
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Stopping sound

Post by minmay »

Er...what on earth do you mean by "party is disabled"?
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Re: Stopping sound

Post by Granamir »

minmay wrote:Er...what on earth do you mean by "party is disabled"?
this:

Code: Select all

for i = 1, 4 do
	party.party:getChampion(i):setEnabled(false)
end
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Stopping sound

Post by minmay »

Oh. Yes, if all 4 party members are disabled, no 3d or ambient sounds will be heard. The solution is don't do that in a situation where you want 3d or ambient sounds to be heard.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Re: Stopping sound

Post by Granamir »

unfortunatelly i can't because of story reasons so i guess i have to use playSound with some limitations
Ty anyway
Post Reply