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

A switch that affects another switch

Recommended Posts

I've been trying to make a switch that enables another switch in a way that the disabled switch first has a repeatable action that triggers a "no power" hud message script, and after the power switch is on, the first switch will not have a repeatble action anymore, and will instead lower a ceiling. First I tried variables, then using "setlinespecial" and "line_setidentification", but the repeatable action property that needs to be disabled is the problem (my problem I mean, i have no idea how to do it). Perhaps there's something i'm not seeing, does anyone know how to do this? Thanks a lot!

Share this post


Link to post

Once there is power and player uses the first repeatable switch, call "line_setspecial" again to change the action again, give it some kind of action that cannot be performed (maybe open a door of unknown tag?) and use setlinetexture to prevent the switch from animating back. It's a hacky solution and perhaps it won't work at all, it's an untested idea; there might easily be a better solution I don't know.

Share this post


Link to post

Hey that sounds brilliant, it's gotta work, let me try it

Share this post


Link to post

I haven't used acs in a long time, going from memory, something like:

int powerOff=1
int finishedScript1=0

script 1 whatever bla
if powerOff==1:
print 'no power'

else if powerOff==0 and finishedScript1==0:
finishedScript1=1
lower ceiling



finishedScript1 becomes 1, thus the action isn't repeatable. I think the switch does acs_execute or whatever of script 1, and then the other switch does acs execute of switch 2 (which makes poweroff=0). My basic guess, untested.

Share this post


Link to post
gggmork said:

finishedScript1 becomes 1, thus the action isn't repeatable.

But then, the switch will still animate and make a sound when pressed, also it will animate back after the first "powered-on" press. My solution *should be* proof of that.

Share this post


Link to post

If you're using a ZDoom build/version that supports it, you can use SetLineActivation ACS function to make the switch unactivatable after the first time it's activated since the power has been restored:

int power;

Script 1 (void) // The "disabled" switch
{
  If(power == 0)
    Print(s:"There seems to be no power!");

  Else
  {
    // Put the action you want to happen, here, when power is restored and the switch is activated

    SetLineActivation(<lineid>, SPAC_None); // Set it so it cannot be activated again
  }
}

Script 2 (void) // The power switch
{
  power = 1;
  Print(s:"Power is restored!");
}

Share this post


Link to post

Thanks everyone. I ended up making it so that the linedef is set a 0 action after the ceiling goes up. Not only because of this post but also because of many other problems you all helped me with, I'm going to credit you when I release this project (probably next year though)

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
×