Hey hey, looks like a script guru in the making. You've got the right idea here, but you'll want to compress this script. Try something like this
void OnStart()
{
//here we'll add the lever callbacks
for(int i=1;i<=3;i++) SetEntityConnectionStateChange("lever"+i, "LeverPull");
}
void LeverPull(string &in leverName, int leverState)
{
// if lever is at correct state, set it stuck and add 1 to lever var
if(leverState == 1)
{
AddLocalVarInt("leverStates", 1);
SetLeverStuckState(leverName, 1, true);
}
// solve the puzzle if all states are 1
if(GetLocalVarInt("leverStates") == 3) func01();
}
void func01()
{
//puzzle solved! hoorah!
SetSwingDoorLocked("prison_cellardoor", false, true);
PlaySoundAtEntity("", "unlock_door", "prison_cellardoor", 0, false);
GiveSanityBoostSmall();
}
This is a cleaner way to do the code. Instead of having a separate function for each lever pulled, I combined them into one. There's no real need to track exactly which lever was pulled, so the script becomes even shorter, since the what we're focusing on is the lever changing states, not on
which lever changes states.
Things I changed:
Compressed the call stack which adds the connection state callbacks.
Compressed the lever pull functions into a single function. Also changed the name to "LeverPull".
The local variable name.
Hope it works for ya. I had to put down my apple to write this....now I'm gonna pick it up and devour the rest of it.