Frictional Games Forum (read-only)
Unexpected token "{" error from this script. - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Unexpected token "{" error from this script. (/thread-8265.html)



Unexpected token "{" error from this script. - dasde - 05-26-2011

Hello

I have this script on a map where I want two leaders to add 1 and 7 to a local int, when int is 8 a Swing door should unlock.

But instead I just get the error "Unexpected token "{"" when I try to launch the game map.

Here is the script:

Code:
void AddLocalVarInt(string& Unlock, int alVal);
{

        if(GetLocalVarInt("Unlock")==8)
        {
           SetLevelSwingDoorLocked(mansion_1, false);
          
        }
}    
void OnLeverStateChange(string &in Lever1, int alState)
{

    AddDebugMessage(Lever1 + "'s current state: " + alState, false);

    if (alState == -1)
    {
     AddLocalVarInt("Unlock", 1);

    }
}

Thank you for your help


RE: Unexpected token "{" error from this script. - Greven - 05-26-2011

(05-26-2011, 08:11 PM)dasde Wrote: Hello

I have this script on a map where I want two leaders to add 1 and 7 to a local int, when int is 8 a Swing door should unlock.

But instead I just get the error "Unexpected token "{"" when I try to launch the game map.

Here is the script:

Code:
void AddLocalVarInt(string& Unlock, int alVal);
{

        if(GetLocalVarInt("Unlock")==8)
        {
           SetLevelSwingDoorLocked(mansion_1, false);
          
        }
}    
void OnLeverStateChange(string &in Lever1, int alState)
{

    AddDebugMessage(Lever1 + "'s current state: " + alState, false);

    if (alState == -1)
    {
     AddLocalVarInt("Unlock", 1);

    }
}

Thank you for your help

At the "void AddLocalVarInt(string& Unlock, int alVal);" There shouldnt be a ; at the end.



RE: Unexpected token "{" error from this script. - dasde - 05-27-2011

Okay, now I get this error: (see attachment)

Here is the full script:

Code:
//===========================================
     // Starter's Script File!
     //===========================================

     //===========================================
     // This runs when the map first starts
     void OnStart()
     {

     }





     //===========================================
     // This runs when the player enters the map
     void OnEnter()
     {
     }

     //===========================================
     // This runs when the player leaves the map
     void OnLeave()
     {
     }
    
    
     //===========================================
     // Areas




////////////////////////////////////////
//UNLOCK START SWINGDOOR

void AddLocalVarInt(string& UnlockDoor, int alVal)
{

        if(GetLocalVarInt("UnlockDoor")==8)
        {
           SetLevelSwingDoorLocked(mansion_1, false);
          
        }
}    
void OnLeverStateChange(string &in Lever1, int alState)
{

    AddDebugMessage(Lever1 + "'s current state: " + alState, false);

    if (alState == -1)
    {
     AddLocalVarInt("UnlockDoor", 1);

    }
}


void OnLeverStateChange(string &in Lever7, int alState)
{
    AddDebugMessage(Lever7 + "'s current state: " + alState, false);

    if (alState == -1)
    {
     AddLocalVarInt("UnlockDoor", 7);
    }
}




RE: Unexpected token "{" error from this script. - Greven - 05-27-2011

hmm.. i dont know alot with the whole "if" thing but when it says mansion_1 is not declared it means it needs "". Like this SetLevelSwingDoorLocked("mansion_1", false);


RE: Unexpected token "{" error from this script. - dasde - 05-27-2011

Fixed it by myself.

This is my script for future googlers:
Code:
void OnLeverStateChange(string &in Lever1, int alState)
{
        if (alState == -1)
        {
            AddLocalVarInt("Var01", 1);
        }    

}

void OnLeverStateChange1(string &in Lever7, int alState)
{
        if (alState == -1)
        {
            AddLocalVarInt("Var01", 7);
        }
}