Frictional Games Forum (read-only)
[SCRIPT] SOLVED Collide function doesn't wanna work - 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] SOLVED Collide function doesn't wanna work (/thread-25015.html)



SOLVED Collide function doesn't wanna work - Neelke - 04-06-2014

For some reason, my collide function isn't functioning properly. It's made by string variables to check if the correct things are pressed and so on.

Code:
void ButtonPress(string &in asEntity)
{
    //Check which button that is currently being pressed
    if(asEntity == "button_simple_1")
    {
        SetLocalVarString("Brother", "CurrentTeleportCutscene");
        
        //Don't want the other buttons to be clicked at this point
        for(int i=0;i<5;i++) SetEntityInteractionDisabled("button_simple_" + i, true);
    }

void CollideChangeMap(string &in asParent, string &in asChild, int alState)
{
    string sMapChange = GetLocalVarString("CurrentTeleportCutscene");
    
    if(sMapChange == "Brother"){
        ChangeMap("nomapyet.map", "TeleEnter_1", "", "");
    }
}

void OnStart()
{
     AddEntityCollideCallback("Player", "AreaChangeMap", "CollideChangeMap", true, 1);
}

I have checked the name of the area and it is correct. Still doesn't wanna work. Just making sure here, is there anything wrong in the script?


RE: Collide function doesn't wanna work - RaideX - 04-06-2014

Try changing "SetLocalVarString("Brother", "CurrentTeleportCutscene");" the other way around to "SetLocalVarString("CurrentTeleportCutscene", "Brother");" because the first input is the name of the string and the second is the value of the string.

That way (sMapChange == "Brother") returns true and the block of code can be executed.


That might be the issue. I'm not entirely sure though.


RE: Collide function doesn't wanna work - Lizard - 04-06-2014

(04-06-2014, 12:35 PM)Neelke Wrote: For some reason, my collide function isn't functioning properly. It's made by string variables to check if the correct things are pressed and so on.

Code:
void ButtonPress(string &in asEntity)
{
    //Check which button that is currently being pressed
    if(asEntity == "button_simple_1")
    {
        SetLocalVarString("Brother", "CurrentTeleportCutscene");
        
        //Don't want the other buttons to be clicked at this point
        for(int i=0;i<5;i++) SetEntityInteractionDisabled("button_simple_" + i, true);
    }

void CollideChangeMap(string &in asParent, string &in asChild, int alState)
{
    string sMapChange = GetLocalVarString("CurrentTeleportCutscene");
    
    if(sMapChange == "Brother"){
        ChangeMap("nomapyet.map", "TeleEnter_1", "", "");
    }
}

void OnStart()
{
     AddEntityCollideCallback("Player", "AreaChangeMap", "CollideChangeMap", true, 1);
}

I have checked the name of the area and it is correct. Still doesn't wanna work. Just making sure here, is there anything wrong in the script?

Your void ButtonPress isnt close correctly. You're missing a }


RE: Collide function doesn't wanna work - Neelke - 04-06-2014

Raidex - That did it, it now changed map just as I wanted it to, thanks.

Lizard - For some reason that } wasn't copied over from my script, so yeah thanks for spending your time anyway Smile