Cacodemon
User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > ACS switch question.
 
Author
All times are GMT. The time now is 01:45. Post New Thread    Post A Reply
neubejiita
Forum Regular


Posts: 682
Registered: 02-09


Hello. I have a switch in a Zdoom UDMF map that triggers a Blue key specific script.
code:
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.

Old Post Apr 1 2013 06:26 #
neubejiita is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
pablogener
Junior Member


Posts: 102
Registered: 11-12


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...
}


}

Old Post Apr 1 2013 06:42 #
pablogener is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Graf Zahl
Why don't I have a custom title by now?!


Posts: 8029
Registered: 01-03


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.

Old Post Apr 1 2013 07:43 #
Graf Zahl is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
Blue Shadow
Member


Posts: 313
Registered: 09-12



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.

Last edited by Blue Shadow on Apr 1 2013 at 15:40

Old Post Apr 1 2013 14:23 #
Blue Shadow is offline || Blog || PM || Post History || Add Buddy IP || Edit || Quote
All times are GMT. The time now is 01:45. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > ACS switch question.

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.