10-14-2011, 12:33 AM
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.
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.
Code:
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(HasItem("catleenakey")=true){
SetEntityActive("tablechair_*", true);
SetEntityActive("chairattable_*", false);
}
}
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.