Frictional Games Forum (read-only)
[SCRIPT] Scripting/Variables 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] Scripting/Variables problem. (/thread-20181.html)

Pages: 1 2


RE: Scripting/Variables problem. - Your Computer - 02-09-2013

I cleaned up your code a bit and fixed several issues that i spotted from it. I cannot test this code, nor can i guarantee anything will work, but, assuming there are no syntax errors, something should at least happen. Note, to point out some of the issues with your code: you weren't adding to the local map variables anywhere, so the map variables Area_5 and Area_6 would never equal 5 or 6; you were checking for 0 for the callback states, when you should have been checking for -1, since the callback state would never equal 0; even though the if statements you had to check against the callback states weren't necessarily wrong, since the state can only have two states and so only one block of code would be executed, but logically you'd want to toss in "else" somewhere in there; you also repeated yourself in some way unnecessarily.

PHP Code:
void OnEnter()
{
    
//
}

void OnStart()
{
    
SetEntityPlayerLookAtCallback("weepingangel""Callback"true);
    
AddEntityCollideCallback("Player""ScriptArea_1""dreamarea"true0);
    
AddEntityCollideCallback("Player""Area_2""boo1"true0);
    
AddEntityCollideCallback("Player""Area_3""CheckAreas"false0);
    
AddEntityCollideCallback("Player""Area_4""CheckAreas"false0);
    
AddEntityCollideCallback("Player""Area_5""CheckAreas"false0);
    
AddEntityCollideCallback("Player""Area_6""CheckAreas"false0);
}

void Callback(string &in asEntityint alState)
{
    
AddEntityCollideCallback("Player""Area""surprisemotherfucker"true0);
}

void surprisemotherfucker(string &in asParentstring &in asChildint alState)
{
    
SetEntityPlayerLookAtCallback("weepingangel_1""Callback1"true);
    
SetEntityActive("weepingangel"false);
    
SetEntityActive("weepingangel_1"true);
    
SetEntityActive("Area_3"true);
    
SetEntityActive("Area_4"true);
    
SetEntityActive("Area_5"true);
    
SetEntityActive("Area_6"true);
}

void boo1(string &in asParentstring &in asChildint alState)
{
    
SetEntityPlayerLookAtCallback("weepingangel_1""Callback2"true);
}

void Callback1(string &in asEntityint alState)
{
    
GiveSanityDamage(20.00true);
    
AddUseItemCallback("""Hammer""weepingangel_1""lolno"false);
    
AddUseItemCallback("""Hammer""weepingangel_3""lolno"false);
    
AddUseItemCallback("""Hammer""weepingangel_4""lolno"false);
    
AddUseItemCallback("""Hammer""weepingangel_5""lolno"false);
    
AddUseItemCallback("""Hammer""weepingangel_6""lolno"false);
}

void CheckAreas(string &in asParentstring &in asChildint alState)
{

    if (
alState == 1)
    {
        
SetLocalVarInt("InsideArea"1);
        
SetLocalVarInt(asChild1);
    }

    else if (
alState == -1)
    {
        
SetLocalVarInt("InsideArea"0);
        
SetLocalVarInt(asChild0);
    }
}

void Callback2(string &in asEntityint alState)
{
    if (
GetLocalVarInt("InsideArea") == 1)
    {
        if (
alState == 1)
        {
            
//
        
}

        else if (
alState == -1)
        {
            
int suffix 0;
            for (
int i 37; ++i)
            {
                if (
GetLocalVarInt("Area_"+i) == 1)
                {
                    
suffix i;
                    break;
                }
            }
            
            if (
suffix != 0)
            {
                
FadeOut(0.50);
                
FadeIn(1.50);
                
GiveSanityDamage(5true);
                
SetEntityActive("WeepingAngel_1"false);
                
SetEntityActive("WeepingAngel_3"false);
                
SetEntityActive("WeepingAngel_4"false);
                
SetEntityActive("WeepingAngel_5"false);
                
SetEntityActive("WeepingAngel_6"false);
                
SetEntityActive("WeepingAngel_"+suffixtrue);
            }
        }
    }