Hellcow

Joined: 17 Jan 2007 Posts: 100 Location: Denmark
|
Posted: Sun Feb 25, 2007 10:26 am Post subject: Lever Puzzle |
|
|
Since Christoph077 confirmed this script works, I suppose I should post it here in the vault for all to use.
The request for the puzzle was to have ten levers, the PC needs to spell a word to unlock the door, if misspelled the script will reset and the door will of course not open.
Example: 10 levers each lever has a letter assigned to it A,D,E,T,W,Y,S,U,R,L: The PC has to pull only the levers that spell W,A,T,E,R.
You need to place a variable on each of your levers that spell: WATER
The lever named W needs to have a int variable named: Lever_W sat to 1
The lever named A needs likewise to have a variable named: Lever_A sat to one - and so on with the rest of your levers, each a variable with the letter they are named. Then place script below in the OnUsed script of all your levers.
The script can easily be modified to spell other words, you'll just have to change the variable name in the script and the letter you place on your levers.
| Code: |
//23.02.07 Lever puzzle by Hellcow
void main()
{
object oPC = GetLastUsedBy();
if (!GetIsPC(oPC)) return;
if (GetLocalInt(OBJECT_SELF, "Lever_W")== 1)
{
SetLocalInt(oPC, "spelling", 1);
FloatingTextStringOnCreature("You hear a click as you pull the lever", oPC);
return;
}
if (GetLocalInt(OBJECT_SELF, "Lever_A")== 1)
{
if (GetLocalInt(oPC, "spelling")== 1)
{
SetLocalInt(oPC, "spelling", 2);
FloatingTextStringOnCreature("You hear a click as you pull the lever", oPC);
return;
}
FloatingTextStringOnCreature("You pull the lever but nothing happens", oPC);
SetLocalInt(oPC, "spelling", 0);
return;
}
if (GetLocalInt(OBJECT_SELF, "Lever_T")== 1)
{
if (GetLocalInt(oPC, "spelling")== 2)
{
SetLocalInt(oPC, "spelling", 3);
FloatingTextStringOnCreature("You hear a click as you pull the lever", oPC);
return;
}
FloatingTextStringOnCreature("You pull the lever but nothing happens", oPC);
SetLocalInt(oPC, "spelling", 0);
return;
}
if (GetLocalInt(OBJECT_SELF, "Lever_E")== 1)
{
if (GetLocalInt(oPC, "spelling")== 3)
{
SetLocalInt(oPC, "spelling", 4);
FloatingTextStringOnCreature("You hear a click as you pull the lever", oPC);
return;
}
FloatingTextStringOnCreature("You pull the lever but nothing happens", oPC);
SetLocalInt(oPC, "spelling", 0);
return;
}
if (GetLocalInt(OBJECT_SELF, "Lever_R")== 1)
{
if (GetLocalInt(oPC, "spelling")== 4)
{
FloatingTextStringOnCreature("You hear a click as you pull the lever and the door opens.", oPC);
//Open door
object oDoor = GetObjectByTag("door_tag");
SetLocked(oDoor, FALSE);
AssignCommand(oDoor, ActionOpenDoor(oDoor));
return;
}
FloatingTextStringOnCreature("You pull the lever but nothing happens", oPC);
SetLocalInt(oPC, "spelling", 0);
return;
}
FloatingTextStringOnCreature("You pull the lever but nothing happens", oPC);
SetLocalInt(oPC, "spelling", 0);
return;
} |
|
|