neubejiita Posted April 1, 2013 Hello. I have a switch in a Zdoom UDMF map that triggers a Blue key specific script. script 2 (void) { if (CheckInventory("BlueSkull")) { Elevator_RaiseToNearest(17, 8); Floor_LowerToLowest(18, 8); // More code here } else Print(s:"You need the Blue skull key to enter."); } . But if I do not have the key, the switch will trigger and then I cannot trigger it again once I have the key. Is there a way to make this triggerable once only; but put in a condition where the Script_Execute() function will check for a key? This function must not be repeatable. 0 Share this post Link to post
pablogener Posted April 1, 2013 you could set up a global variable, and give it a value the first time you run through your function. if it's the second or forth-on time you're in for the function, you would exit it without doing anything. I would do sth like this: int myFlag = 0 script 1 (void) { if (myFlag == 0) { myFlag = 1; //loads of code here... } } 0 Share this post Link to post
Graf Zahl Posted April 1, 2013 You should use ACS_LockedExecute for stuff like this. If you want a different message than the standard one you can define a new lock in LOCKDEFS for that purpose. Then you won't have to check the key yourself in your script. 0 Share this post Link to post
Blue Shadow Posted April 1, 2013 neubejiita said:Is there a way to make this triggerable once only; but put in a condition where the Script_Execute() function will check for a key? This function must not be repeatable. There is, with ACS_ExecuteWithResult (see the paragraph above the second example in the page). ----- Edit: I should've mentioned that this is just an alternate solution, and on second thought, I think it's easier to go with what Graf suggested above. 0 Share this post Link to post