const string[] lever_names = {"LEVER1", "LEVER2", "LEVER3", "LEVER4"}
const int[] desired_lever_states = {1, 1, -1, 1}
/******************************************************************************/
void OnStart()
{
SetEntityConnectionStateChangeCallback("LEVER1", "lever_func");
SetEntityConnectionStateChangeCallback("LEVER2", "lever_func");
SetEntityConnectionStateChangeCallback("LEVER3", "lever_func");
SetEntityConnectionStateChangeCallback("LEVER4", "lever_func");
SetLocalVarInt("LEVER1", 0);
SetLocalVarInt("LEVER2", 0);
SetLocalVarInt("LEVER3", 0);
SetLocalVarInt("LEVER4", 0);
}
/******************************************************************************/
void lever_func(string &in asEntity, int alState)
{
if (GetLocalVarInt("LEVER_PUZZLE_COMPLETE") == 1)
return;
SetLocalVarInt(asEntity, alState);
CheckFunction();
}
/******************************************************************************/
void CheckFunction()
{
for (int i = 0; i < lever_names.length(); ++i)
{
if (GetLocalVarInt(lever_names[i]) != desired_lever_states[i])
return;
else
{
SetLeverStuckState(lever_names[i], desired_lever_states[i], true);
SetEntityConnectionStateChangeCallback(lever_names[i], "");
}
}
GiveSanityBoost();
SetSwingDoorLocked("LEVERDOOR", false, true);
SetLocalVarInt("LEVER_PUZZLE_COMPLETE", 1);
}