(09-18-2013, 11:13 AM)LankySpankey103 Wrote: How come when you hover the mouse over the "full game save" property, it says that I should use as few of them as possible?
Every entity you enable full game save on is in the save file forever - so if you did this for loads of entities each map the save file will grow pretty big. It's fine to use for a select few props which you need to remember the state of between maps.
Regarding your code, it looks like it should work provided you visit map 1 first and are pulling the levers in the right direction. Changing the code to the following will allow us to test where stuff is going wrong.
First map:
void OnStart()
{
/*GetGlobalVarInt('<stuff>') returns 0 if SetGlobalVarInt hasn't been called yet, so we don't need to init this to 0*/
}
void OnEnter()
{
//Print some debug messages so we can see the lever states
AddDebugMessage("Map1 OnEnter()",false);
AddDebugMessage("lever_grave state: " + GetGlobalVarInt("lever_grave_pulled"),false);
AddDebugMessage("lever_torture state: " + GetGlobalVarInt("lever_torture_pulled"),false);
//Unlock the level door if both levers have been pulled
if(GetGlobalVarInt("lever_grave_pulled") + GetGlobalVarInt("lever_torture_pulled") == 2)
{
AddDebugMessage("Opening level door!",false);
SetLevelDoorLocked("level_wood_double_1", false);
}
}
Second map:
void OnStart()
{
SetEntityConnectionStateChangeCallback("lever_grave", "lever_exit_1");
}
void lever_exit_1(string &in asEntity, int alState)
{
//This helps us know if this event has triggered
AddDebugMessage(asEntity + " is in state: " + alState,false);
if (alState == 1)
{
SetGlobalVarInt("lever_grave_pulled", 1);
SetLeverStuckState("lever_grave", 1, true);
}
}
Third Map
void OnStart()
{
SetEntityConnectionStateChangeCallback("lever_torture", "lever_exit_2");
}
void lever_exit_2(string &in asEntity, int alState)
{
//This helps us know if this event has triggered
AddDebugMessage(asEntity + " is in state: " + alState,false);
if (alState == 1)
{
SetGlobalVarInt("lever_torture_pulled", 1);
SetLeverStuckState("lever_torture", 1, true);
}
}