
Pull Chain for Shower
Moderator: Event DM
- 4x4_Ender
- Sage
- Posts: 1782
- Joined: Wed Jun 04, 2003 11:26 pm
- Location: Woodbury, MN (GMT -6)
- Contact:
Pull Chain for Shower
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?? 

"Many make a trade of delusions and false miracles, deceiving the stupid multitude." -Leonardo Da Vinci
- 4x4_Ender
- Sage
- Posts: 1782
- Joined: Wed Jun 04, 2003 11:26 pm
- Location: Woodbury, MN (GMT -6)
- Contact:
Right. So how do you do that??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...

"Many make a trade of delusions and false miracles, deceiving the stupid multitude." -Leonardo Da Vinci
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);
}
- 4x4_Ender
- Sage
- Posts: 1782
- Joined: Wed Jun 04, 2003 11:26 pm
- Location: Woodbury, MN (GMT -6)
- Contact:
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.

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);
}
}
"Many make a trade of delusions and false miracles, deceiving the stupid multitude." -Leonardo Da Vinci
Oooo... a shower...


<Sili> I've seen septic tanks with less shit in them than Fuzz.
<Ronnin> damm not even a kiss??
<Chasmania> Kiss Fuzz? I'd rather fellate a goat.
<Chasmania> there are many roads to Rome..they just picked a shit filled alley full of scabby hookers and bums.
The shape of things to come...
<Ronnin> damm not even a kiss??
<Chasmania> Kiss Fuzz? I'd rather fellate a goat.
<Chasmania> there are many roads to Rome..they just picked a shit filled alley full of scabby hookers and bums.
The shape of things to come...
- Baratin Gilden
- Lord of Blithering Idiots
- Posts: 134
- Joined: Wed Dec 25, 2002 6:22 pm
- Location: Stirling; Scotland.
- Neve
- Prince of Bloated Discourse
- Posts: 192
- Joined: Mon Apr 14, 2003 4:09 pm
- Location: The Netherlands
- Contact:
"Drip" goes down =p
- As you gaze unknowingly into the seemingly infinite depths of the optics of this altogether passionate embodiment of insatiability, you experience a gradual realisation that the heavily-embellished vocabulary scattered lavishly throughout the sentence you are currently reading is indisputably nothing greater than a generous ration of masculine bovine faeces.