Page 1 of 1
Pull Chain for Shower
Posted: Fri Sep 05, 2003 2:27 am
by 4x4_Ender
I put a shower room in my house that I designed. Now, ive figured out how to have a pull chain play the SoundObject placed in the shower using the SoundObjectPlay() command. So, when someone pulls the chain infront of it, the sound plays fine. But, I want to make it so you can turn the same SoundObject off with the same pull chain if the sound is running. Im guessing this would involve some kind of If/Then statement to determine if the sound is on or off and to apply the appropriate command. But, im not sure how to code this. Can anyone help a newbie scripter here??

Posted: Fri Sep 05, 2003 2:30 am
by Jordicus
not sure which is more efficient / or easier, but you could either do a check to see if the sound is playing already, or you could store a true/false local variuable on the chain itself to indicate the sound status and just quesry that...
Posted: Fri Sep 05, 2003 2:40 am
by 4x4_Ender
Jordicus wrote:not sure which is more efficient / or easier, but you could either do a check to see if the sound is playing already, or you could store a true/false local variuable on the chain itself to indicate the sound status and just quesry that...
Right. So how do you do that??

Posted: Fri Sep 05, 2003 3:07 am
by Myk D'vor
Code: Select all
object chain = OBJECT_SELF;
int toggle = GetLocalInt(chain,"Shower on");
if(toggle == 0)
{ // the shower's not on, this is also the default state of the local if it was never set
play the sound
SetLocalInt(chain,"Shower on",TRUE);
} else {
// shower's already on
turn off the sound
SetLocalInt(chain,"Shower on",FALSE);
}
Myk
Posted: Fri Sep 05, 2003 3:39 am
by 4x4_Ender
Ha!! Myk, your a genius!! Now I know how to do If/Then statements using the crappy NWN scripting language. Thanks ALOT!!
Here is the finished script in case anyone is interested.
Code: Select all
// Placed on the OnUsed event of a Pull Chain;
// plays a sound object of dripping water created with the sound wizard
void main()
{
object oSound = GetObjectByTag("WaterDrippingLoop1");
object chain = OBJECT_SELF;
int toggle = GetLocalInt(chain,"Shower on");
if(toggle == 0)
{ // the shower's not on, this is also the default state of the local if it was never set
SoundObjectPlay(oSound);
object oPC = GetLastUsedBy();
SendMessageToPC(oPC, "Clean water rushes over you");
SetLocalInt(chain,"Shower on",TRUE);
}
else {
// shower's already on
SoundObjectStop(oSound);
SetLocalInt(chain,"Shower on",FALSE);
}
}
Posted: Fri Sep 05, 2003 4:13 am
by Fuzz
Oooo... a shower...

Posted: Fri Sep 05, 2003 4:22 am
by Myk D'vor
Wow, if that gets a 'genius', I definitely don't want to show you the special storage chests, you'd die of neural shock.
Myk
Posted: Fri Sep 05, 2003 1:53 pm
by Baratin Gilden
How would you script it that a water animation decends on the shower area on the chain pull on and off?
There's a number of magical light effects that go up the way, by I've not seen one that comes down?
Posted: Fri Sep 05, 2003 2:18 pm
by Neve
"Drip" goes down =p