Workable lever
From NWNWiki
Workable lever is a custom function. When placed in the OnUsed of a lever, it will play its animation and return a TRUE (ON) or FALSE (OFF) state to the script. The script can either be added to a include file, or added to the top of the void main() script as in the example script below.
[edit] Script Notes
- When useing a lever, be sure to set its "Initial State" to "Deactivated"
[edit] The Script
///////////////////////////////////////////////////////
// Place the Lever and set it State to "Deactivated"
// Use in the OnUsed of a Lever or switch
///////////////////////////////////////////////////////
int FlipSwitch(object oLever = OBJECT_SELF)
{
//lever animation
if (GetLocalInt(OBJECT_SELF,"nToggle") == 0)
{
PlayAnimation(ANIMATION_PLACEABLE_ACTIVATE,1.0,1.0);
SetLocalInt(OBJECT_SELF,"nToggle",1);//set "ON"
return TRUE;
}
else
{
PlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE,1.0,1.0);
SetLocalInt(OBJECT_SELF,"nToggle",0);//set "OFF"
return FALSE;
}
//end level anaimation
}
void main()
{
if(FlipSwitch())
{
// Add code for ON state
}
else
{
// Add code for OFF state, if you wish
}
}
