Frictional Games Forum (read-only)
[SCRIPT] Quick Lever Problem - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Quick Lever Problem (/thread-23775.html)



Quick Lever Problem - 3gamers - 11-03-2013

Okay so there's four levers that need to be pulled to unlock the door. I've written the script using the wiki http://wiki.frictionalgames.com/hpl2/tutorials/script/levers_and_secretshelfs so it's kind of frustrating that it doesn't work.
Someone please help. I would GREATLY appreciate it.
I've checked and double checked all the names so that's not the problem.

void OnStart()
{
SetLocalVarInt("Var1", 0);
SetEntityConnectionStateChangeCallback("Lever1", "func1");
SetEntityConnectionStateChangeCallback("Lever2", "func2");
SetEntityConnectionStateChangeCallback("Lever3", "func3");
SetEntityConnectionStateChangeCallback("Lever4", "func4");
}

void func1(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
}
}

void func2(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
}
}

void func3(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
}
}

void func4(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
}
}

void func5()
{
if(GetLocalVarInt("Var1") == 4)
{
SetLevelDoorLocked("level_cistern_1", false);
}
}


RE: Quick Lever Problem - Rapture - 11-03-2013

If your stuck in a scripting problem, add "AddDebugMessage(string& asString, bool abCheckForDuplicates);" to your functions. Makes it a lot easier to isolate your issue(s) before posting on the forums.

void func1(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
AddDebugMessage("func1 = Var1 + " Var1, true);
}
}

void func2(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
AddDebugMessage("func2 = Var1 + " Var1, true);
}
}

void func3(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
AddDebugMessage("func3 = Var1 + " Var1, true);
}
}

void func4(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
AddDebugMessage("func4 = Var1 + " Var1, true);

}
}

void func5()
{
if(GetLocalVarInt("Var1") == 4)
{
SetLevelDoorLocked("level_cistern_1", false);
AddDebugMessage("func5 = Var1 + " Var1, true);
}
}



("func4 = Var1 + " Var1) is just to check your variables are working, might never know when you mess something up as simple as that.


RE: Quick Lever Problem - Daemian - 11-03-2013

I think the script it's working fine, the door may be the problem.
Try with a normal door instead of a level-door.

And put the debug messages Rapture said.


RE: Quick Lever Problem - PutraenusAlivius - 11-03-2013

Spoiler below!

PHP Code:
void OnStart()
{
for(
int x 0== 4x++) SetEntityConnectionStateChangeCallback("Lever*"+i"func*"+i);
}

void func(string &in asEntityint alState)
{
if (
alState == 1)
{
SetLocalVarInt("Var1"+asName1);
IsItDone();
AddDebugMessage("First test succeed!"false);
}
}

void IsItDone()
{
if(
GetLocalVarInt("Var1Lever1_1") == && GetLocalVarInt("Var1Lever2_2") == && GetLocalVarInt("Var1Lever3_3") == && GetLocalVarInt("Var1Lever4_4") == 1)
{
SetLevelDoorLocked("level_cistern_1"false);
AddDebugMessage("Door is now unlocked! Also, testing 2 is done."false);
}



Whipped this out. Dunno if it's right. Not tested yet.