Frictional Games Forum (read-only)
Unexpected token 'if' - 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: Unexpected token 'if' (/thread-17124.html)



Unexpected token 'if' - Redneb27 - 07-20-2012

If this is answered somewhere else, I'm sorry. I looked for hours. Really. I can't for the life of me figure out what is wrong. I tried to add an intro sequence, and i pretty much copied this one -
http://wiki.frictionalgames.com/hpl2/tutorials/script/sequences- and now I have an unexpected token 'if' error.


////////////////////////////
// Run when entering map
void OnEnter()
{
SetLocalVarInt("iIntroPart", 0);
AddTimer("tmrIntro", 1.0f, "introSequence");
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);
SetEntityConnectionStateChangeCallback("lever_simple01_1", "UnlockDoor");
SetEntityPlayerInteractCallback("key_2", "ActivateMonster", true);
AddEntityCollideCallback("Player", "Brute_Moan", "ScarePlayer", true, 1);
SetLevelDoorLocked("level_wood_1", true);
AddUseItemCallback("", "key_2", "level_wood_1", "UsedKeyOnDoor2", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);
RemoveItem("key_1");
}

void introSequence(string &in asTimer)
{
AddLocalVarInt("iIntroPart", 1);
float partSpeed = 1.5f;
switch (GetLocalVarInt("iIntroPart"));
{
case 1:
partSpeed = 21.0f;
FadeOut (0.0f);
FadePlayerRollTo(50, 220, 220);
FadeIn(20,0f);
break;
case 2:
partSpeed = 10. 0f;
FadePlayerRollTo(0.0f, 33.0f, 33.0f);
break;
}
}

if (GetLocalVarInt ("iIntroPart") <2)
{
AddTimer("tmrIntro", partSpeed, "introSequence");
}

void ScarePlayer(string &in asParent, string &in asChild, int alState)
{
PlayMusic("enabled01.ogg", false, 0.6, 2, 1, true);

}

void ActivateMonster(string &in asEntity)
{
SetEntityActive("servant_brute_1", true);
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_7", 0, "");
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_8", 4, "");
}


void UnlockDoor(string &in asEntity, int level_state)
{
if (level_state == -1)
{
SetSwingDoorLocked("door_2", false, true);
PlaySoundAtEntity("", "unlock_door", "lever_simple01_1", 0, false);
}

}
////////////////////////////
// Run when leaving map
void OnLeave()
{

}


RE: Unexpected token 'if' - Your Computer - 07-20-2012

The following is out of place:
Code:
if (GetLocalVarInt ("iIntroPart") <2)
{
AddTimer("tmrIntro", partSpeed, "introSequence");
}

It needs to be inside a function body.