Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
neubejiita

ACS switch question.

Recommended Posts

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.

Share this post


Link to post

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


}

Share this post


Link to post

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.

Share this post


Link to post
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.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×