Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Eric the Sandvich

Is there a way to prevent scripts from activating other scripts?

Recommended Posts

I'm curently using ACS, I have a button system for a lift, however the buttons can make the lift go far beyond what it is intended.

 

I just need to know if there is some piece of scripting I haven't heard of that disables and activates scripts within ACS.

Share this post


Link to post

I'm not sure how exactly you want it to work, but you have several possibilities how to implement it.

Calling ScriptWait within a script pauses this script until another script finishes execution.

A script can assign a value to a map scope variable and another script can check the value and either do nothing or do something depending on the value.

SetLineSpecial can be used to assign/clear actions on linedefs.

Share this post


Link to post

If I'm understanding your post correctly, upon hitting a switch; the lift sector floor is raised beyond the height of the floor of the upper sector?

 

If so, I've wrote a script which may serve as an example (based on the assumption that the above is correct).

 

Below is an format example of how this could be approached:

 

//Include the zcommon.acs library
#include "zcommon.acs"
//Perform check to determine if the floor is raised or not
function void raiseCheck(bool raised) {
    if(raised) {
        Floor_LowerToLowest(1, 32);
    } else {
        Floor_RaiseToHighest(1, 32);
    }
}
//Invoked by the higher switch to lower the floor
script 1 (void) {
    raiseCheck(TRUE);
}
//Invoked by the lower switch to raise the floor
script 2 (void) {
    raiseCheck(FALSE);
}

 

To elaborate a little further, let's break it down in a more detailed manner:

 

- The raisedCheck function takes a boolean parameter. When called, it performs a check to determine what the value of raised is equal to. If it is true, then lower the platform to the lowest for.

- Booleans only hold true/false values, so we can then call this function via script 1 and 2 and pass either of those values (although the ACS documentation regarding data types states the language treats these values as 1 and 0 respectively since integers are technically the only supported data type, but I digress...)

- If required, further parameters can be passed into the function which would represent the values of tag and speed (1 and 32 for the in-built Floor_LowerToLowest function call.) 

 

However, there's a caveat to this approach depending on the switch implementation - if the sectors in question are nearby neighbours (meaning linked by a sidedef) of the sector floor that is being raised, the higher of the 2 switches must have the same floor height as the highest joining sector floor. 

 

You could apply a slight remedy by using Floor_RaiseByValue and Floor_LowerByValue, as shown below:

#include "zcommon.acs"
//Takes an extra parameter as we would need to specify the height for the function call in scripts 1 and 2
function void raiseCheck(bool raised, int tag, int speed, int height) {
    if(raised) {
        Floor_LowerByValue(tag, speed, height);
    } else {
        Floor_RaiseByValue(tag, speed, height);
    }
}
//Height in both of these scripts is 64, since the joining lowest and highest sectors are separated by 64 units in height
script 1 (void) {
    raiseCheck(TRUE, 1, 32, 64);
}
script 2 (void) {
    raiseCheck(FALSE, 1, 32, 64);
}

 

You will need to calculate the distance in height between the floor sector that is being raised and the sector which it is being raised to, since the function call above takes an extra parameter (height) or else the lift could raise short of the intended distance. 

 

In the example above, the lift sector floor has a height of 0 and the floor above has a height of 64; so the height parameter is passed as 64 into the function call within script 1 and 2.

 

There's a problem with this as well though. Since Doomguy can activate switches provided he is near enough either switch (regardless of the distance above or below his field of view), the floor could be raised or lowered beyond their purposes. 

 

You could build a sector inside the switch sector with its ceiling equal to the floor height  and close/raise the ceiling whether the lift has been raised or not. Or even create a door sector and then open/close the doors based on if the floor is raised or not, as shown below:

 

#include "zcommon.acs"
function void raiseCheck(bool raised, int tag, int speed, int height) {
    if(raised) {
        Floor_LowerByValue(tag, speed, height);
    } else {
        Floor_RaiseByValue(tag, speed, height);
    }
}
//Closes the door for the higher switch and opens the door for the lower switch
script 1 (void) {
    Door_Close(3, 64, 0);
    Door_Open(2, 64, 0);
    raiseCheck(TRUE, 1, 32, 64);
}
/Closes the door for the lower switch and opens the door for the higher switch
script 2 (void) {
    Door_Close(2, 64, 0);
    Door_Open(3, 64, 0);
    raiseCheck(FALSE, 1, 32, 64);
}

 

Anyway, I've attached the demo wads I made for this so that you can take a look.

 

Note that there are probably better ways of doing this than those listed above, however these are just examples. Feel free to play around with these scripts if you wish.

 

Hope this helps!

 

Examples.zip

Edited by the iron hitman

Share this post


Link to post
31 minutes ago, the iron hitman said:

Anyway, I've attached the demo wads I made for this so that you can take a look.

 

Note that there are probably better ways of doing this than those listed above, however these are just examples. Feel free to play around with these scripts if you wish.

 

Hope this helps!

Holy shit dude, props for helping out but... this was 5 days ago, I already solved it in a simpler way.

 


#include "zcommon.acs"

script 1 open
{
 setlinespecial(1, ACS_execute, 2);
 setlinespecial(2, ACS_execute, 2);
}

script 2 (void)
{
 setlinespecial(2, 0, 0);
 setlinespecial(1, 0, 0);
 delay(40);
 Floor_RaisebyValue(14, 4, 64);
 delay(130);
 setlinespecial(2, ACS_execute, 3);
 setlinespecial(1, ACS_execute, 3);
}

script 3 (void)
{
 setlinespecial(2, 0, 0);
 setlinespecial(1, 0, 0);
 delay(40);
 Floor_LowerbyValue(14, 4, 64);
 delay(130);
 setlinespecial(1, ACS_execute, 2);
 setlinespecial(2, ACS_execute, 2);
}

 

But thanks anyway, I'll take your help into consideration for other scripts.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×