Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about using global variables
Acies Offline
Posting Freak

Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation: 73
#3
RE: Question about using global variables

The following part should be applied to the mapscript which contains the key:
void OnStart
{
SetEntityPlayerInteractCallback("The_Key_name", PickUpCatleena, true);
}

void PickUpCatleena(string &in asEntity)
{SetGlobalVarInt("HasKeyCatleena", 1);
}
[/code]

----------------------------------------------------------------------
Your original script with key:
void OnEnter()
{
    PlayMusic("25_amb.ogg", true, 1.0f, 10.0f, 1, true);
    AddEntityCollideCallback("Player", "keycheck", "keytrigger", false, 1);
}
void keytrigger(string &in asParent, string &in asChild, int alState)
{
        if (GetGlobalVarInt("HasKeyCatleena") == 1){
            SetEntityActive("tablechair_*", true);
            SetEntityActive("chairattable_*", false);
}else//If player doesn't have key - do stuff below
}


Information on variables:
  • Local variables only apply to the specific map - so if the key is in the same map as checked for this will be okay
  • Global variables apply to every map in your story
  • The default value of any variable is always 0
  • Int is integer values: 0, 1, 2, 3 and so forth
  • Float is values with decimals 1.3, 1.45, and so forth

Think of the variable as 0 = false | 1 = true
in the case of checking wheter a puzzle is complete or an item has been picked up.




[Image: mZiYnxe.png]


(This post was last modified: 10-14-2011, 12:50 AM by Acies.)
10-14-2011, 12:49 AM
Find


Messages In This Thread
RE: Question about using global variables - by Acies - 10-14-2011, 12:49 AM



Users browsing this thread: 1 Guest(s)