Question about using global variables - 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: Question about using global variables (/thread-10744.html) |
Question about using global variables - ggstarfoxxie - 10-14-2011 I'm having trouble with a function in one map that needs to check if a player has a key from another map, then execute a scary event only when the player has the key. I've tried the script below as a workaround, but it doesn't behave like I want it to. The "keytrigger" function will still happen, even when I don't have Catleena's key. Code: void OnEnter() I've read you have to use global variables, but I don't know how to use them properly. The wiki doesn't explain how to utilize them, just lists the functions. If someone could explain how to use globals for checking items/completed puzzles, or know of a better workaround, I'd appreciate it. RE: Question about using global variables - Your Computer - 10-14-2011 Concerning your script: it doesn't work because you're trying to assign "true" to a function. You're supposed to have two equal signs in order to return an expected boolean to the conditional if statement. RE: Question about using global variables - Acies - 10-14-2011 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: Code: void OnEnter() Information on variables:
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. RE: Question about using global variables - ggstarfoxxie - 10-14-2011 Thanks for your replies! I fixed the single equals to double equals & used the global functions & it works now, hurray! |