How to use the Sound Game Object

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!
Post Reply
Echoplex
Posts: 63
Joined: Tue Nov 04, 2014 10:59 pm

How to use the Sound Game Object

Post by Echoplex »

So I recently stumbled onto this what seemed to be awesome object to place and utilize however I cant seem to get it to run correctly. I can pick the sound out but it seems to fire off immediately at the start of the level. I tried connecting plates to it to activate when stepped on, disabling sound and controller in the object to stop it from preemptively firing off but all that seems to do is disable it permanently. So my question is: How would I script and match this thing up to fire off at a specific time or place? Thanks
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: How to use the Sound Game Object

Post by GoldenShadowGS »

This is pretty simple: uncheck the sound component if you want it to start silent.

Code: Select all

function soundenable()
	if lever_1.lever:isActivated() then
	sound_1.sound:enable()
	else
	sound_1.sound:disable()
	end
end
Echoplex
Posts: 63
Joined: Tue Nov 04, 2014 10:59 pm

Re: How to use the Sound Game Object

Post by Echoplex »

So I tried to fit that into what I was doing and am still hitting errors. Heres what I have. Im getting errors with the then statement so im not sure where to put it. I tried several different places.

Code: Select all

function laugh()
     if skeleton_commander_1:die();
      die = true; then
     sound_1.sound:enable()
     else
     sound_1.sound:disable()
     end
end
Oxijyn
Posts: 10
Joined: Wed Oct 29, 2014 8:22 pm
Location: Lost in a dungeon.

Re: How to use the Sound Game Object

Post by Oxijyn »

I think you need a .monster after the end of skeleton_commander_1

So like... skeleton_commander_1.monster

Not 100% certain, coding is not something I'm good at.
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: How to use the Sound Game Object

Post by GoldenShadowGS »

if you just want to turn the sound on when a certain enemy is killed, try this:

Do a connector from the monster to the script entity. OnDie, Script_entity_1, soundon

In the script put this:

Code: Select all

function soundon()
sound_1.sound:enable()
end
Echoplex
Posts: 63
Joined: Tue Nov 04, 2014 10:59 pm

Re: How to use the Sound Game Object

Post by Echoplex »

GoldenShadowGS wrote:if you just want to turn the sound on when a certain enemy is killed, try this:

Do a connector from the monster to the script entity. OnDie, Script_entity_1, soundon

In the script put this:

Code: Select all

function soundon()
sound_1.sound:enable()
end
Thanks that ended up working nicely. Is there a reason why you just cant unclick the sound on the sound object and then tie it to on die connector?
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: How to use the Sound Game Object

Post by GoldenShadowGS »

I don't think that type of connection is possible, don't know why.
Post Reply