I have been working on a script for a while and for some reason, it doesn't work the way I want it to work. The player is supposed to pull down 5 levers in a certain order and there are 2 combinations that they can use.
These are the levers: 1 2 3 4 5
Combinations: 4 5 2 1 3
5 1 3 2 4
I don't want the combinations to combine in a way. So this is my somewhat advanced script that should have taken care of it, but doesn't work, yet still can run:
void OnStart()
{
SetLocalVarInt("Lever", 1);
SetEntityConnectionStateChangeCallback("lever_simple01_22", "L1");
SetEntityConnectionStateChangeCallback("lever_simple01_23", "L2");
SetEntityConnectionStateChangeCallback("lever_simple01_24", "L3");
SetEntityConnectionStateChangeCallback("lever_simple01_25", "L4");
SetEntityConnectionStateChangeCallback("lever_simple01_26", "L5");
Check();
}
void Check()
{
if (GetLocalVarInt("Lever") == 6)
{
GiveSanityBoost();
int x = RandInt(1, 2);
if (x == 1)
{
SetSwingDoorLocked("castle_1", false, true);
SetSwingDoorClosed("castle_1", false, true);
return;
}
else if (x == 2)
{
SetSwingDoorLocked("castle_2", false, true);
SetSwingDoorClosed("castle_2", false, true);
return;
}
}
}
void L5(string &in asEntity, int alState)
{
if (alState == 1)
{
if (GetLocalVarInt("Lever") == 4)
{
AddLocalVarInt("Lever", 1);
SetEntityInteractionDisabled("lever_simple_26", true);
return;
}
else if (GetLocalVarInt("Lever") == 3)
{
AddLocalVarInt("Lever", 1);
SetEntityInteractionDisabled("lever_simple_26", true);
return;
}
else if ((GetLocalVarInt("Lever") != 3) || (GetLocalVarInt("Lever") != 4))
{
SetLocalVarInt("Lever", 1);
for (int i = 22; i <= 26 && i >= 22; i++)
{
SetEntityInteractionDisabled("lever_simple01_"+i, false);
}
return;
}
}
}
void L4(string &in asEntity, int alState)
{
if (alState == 1)
{
if (GetLocalVarInt("Lever") == 1)
{
AddLocalVarInt("lever", 1);
SetEntityInteractionDisabled("lever_simple_25", true);
return;
}
else if (GetLocalVarInt("Lever") == 2)
{
AddLocalVarInt("Lever", 1);
SetEntityInteractionDisabled("lever_simple_25", true);
return;
}
else if ((GetLocalVarInt("Lever") != 1) || (GetLocalVarInt("Lever") != 2))
{
SetLocalVarInt("Lever", 1);
for (int i = 22; i <= 26 && i >= 22; i++)
{
SetEntityInteractionDisabled("lever_simple01_"+i, false);
}
return;
}
}
}
void L3(string &in asEntity, int alState)
{
if (alState == 1)
{
if (GetLocalVarInt("Lever") == 3)
{
AddLocalVarInt("lever", 1);
SetEntityInteractionDisabled("lever_simple_24", true);
return;
}
else if (GetLocalVarInt("Lever") == 2)
{
AddLocalVarInt("Lever", 1);
SetEntityInteractionDisabled("lever_simple_24", true);
return;
}
else if ((GetLocalVarInt("Lever") != 3) || (GetLocalVarInt("Lever") != 2))
{
SetLocalVarInt("Lever", 1);
for (int i = 22; i <= 26 && i >= 22; i++)
{
SetEntityInteractionDisabled("lever_simple01_"+i, false);
}
return;
}
}
}
void L2(string &in asEntity, int alState)
{
if (alState == 1)
{
if (GetLocalVarInt("Lever") == 1)
{
AddLocalVarInt("lever", 1);
SetEntityInteractionDisabled("lever_simple_23", true);
return;
}
else if (GetLocalVarInt("Lever") == 5)
{
AddLocalVarInt("Lever", 1);
SetEntityInteractionDisabled("lever_simple_23", true);
return;
}
else if ((GetLocalVarInt("Lever") != 1) || (GetLocalVarInt("Lever") != 5))
{
SetLocalVarInt("Lever", 1);
for (int i = 22; i <= 26 && i >= 22; i++)
{
SetEntityInteractionDisabled("lever_simple01_"+i, false);
}
return;
}
}
}
void L1(string &in asEntity, int alState)
{
if (alState == 1)
{
if (GetLocalVarInt("Lever") == 5)
{
AddLocalVarInt("lever", 1);
SetEntityInteractionDisabled("lever_simple_22", true);
return;
}
else if (GetLocalVarInt("Lever") == 4)
{
AddLocalVarInt("Lever", 1);
SetEntityInteractionDisabled("lever_simple_22", true);
return;
}
else if ((GetLocalVarInt("Lever") != 5) || (GetLocalVarInt("Lever") != 4))
{
SetLocalVarInt("Lever", 1);
for (int i = 22; i <= 26 && i >= 22; i++)
{
SetEntityInteractionDisabled("lever_simple01_"+i, false);
}
return;
}
}
}