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

Can someone help me with a switch ACS script?

Question

Hello;

I created an elevator that is lowered by default, the idea is that you need to activate a switch so that the floor of the elevator raises to a certain level, here is the script for the 1st switch:

-------------------------------------------------------------------

#include "zcommon.acs"


        int lift1;

script 1 (void)
    {
        if (gametype()==GAME_NET_DEATHMATCH){
            terminate;
            }

        lift1 = 1 ;
        changecamera(1,1,0);
        delay(16);
        Floor_MoveToValue(2,12,232);
        print(s:"The lift is now functional");
        delay(160);
        changecamera(0,0,0);
        }

--------------------------------------------------------------------

And there is another switch when you press (when the lift is not activated) nothing happens, but shows a message that says: "the lift is not working" but when you activate it you become able to use the 2nd switch to raise and lower the lift without the message appearing.

 

My question is: how to insert a script for the 2nd switch when the lift is not activated with a message, and when it is activated but without message?

Share this post


Link to post

7 answers to this question

Recommended Posts

  • 0

Alright! I got it working.

 

ACS code for it would be:

#include "zcommon.acs"

bool LiftIsFunctional = FALSE; // Self explanatory.

script "LiftSwitchActivator" (void)
{
    LiftIsFunctional = TRUE; // Self explanatory.
}

script "LiftSwitch" (void)
{
    if (LiftIsFunctional == FALSE) // unsure why you have to use == but whatever
    {
        print(s:"The lift isn't working! Buzz off!"); // feel free to change all the stuff inside of these conditions
    }
    else
    {
        Print(s:"Woo, the lift is working! Jk.");
    }
}

and I have a provided WAD to show it works. 

Gotittowork.rar

Share this post


Link to post
  • 0

Not sure what went wrong mate, perhaps done something from my side, can you please look into it, this is in its very early work: (GZDoom port-doom in hexen format) you can use IDCLIP code to go up and down between the two switches and test, much appreciated btw. 

 

Edited by Genki

Share this post


Link to post
  • 0
39 minutes ago, Genki said:

Not sure what went wrong mate, perhaps done something from my side, can you please look into it, this is in its very early work: (GZDoom port-doom in hexen format) you can use IDCLIP code to go up and down between the two switches and test, much appreciated btw. 

MAP01.7z

Doom in hexen format? Yeah, update it to UDMF. UDMF has the most features & full support for ACS while hexen format is buggy. I'll take a look at it in UDB, but no promises.

Share this post


Link to post
  • 1

@Genki Got it working perfectly! It should work just the way you wanted; no need to update to UDMF. Comments are provided with the scripts, just in case you want to change the effects.

 

Script is here: 

#include "zcommon.acs"

bool LiftIsFunctional = FALSE; 
// This tells us that "LiftIsFunctional" is a boolean variable, so it's either true or false.
// Script 1 turns LiftIsFunctional to True and does the effects you wanted.
// Script 2 checks if LiftIsFunctional is false or true. If it's true, then the lift works fine. If it's false, then it gives an error message.

script 1 (void)
// I'm unsure if I got it exactly the way you wanted it to work, but I tried my best.
// Change the stuff inside of the conditions if I got something wrong or you want a different effect.
{
    if (gametype()==GAME_NET_DEATHMATCH){ // Remember to keep this in while changing effects.
        terminate;
    }
    LiftIsFunctional = TRUE; // Remember to keep this in while changing effects.
    changecamera(1,1,0);
    print(s:"Lift is now functional.");
    delay(160);
    changecamera(0,0,0);
}

script 2 (void) // You shouldn't have to mess with this, since it should work exactly like how you wanted it to.
{
    if (gametype()==GAME_NET_DEATHMATCH){ // Remember to keep this in while changing effects.
        terminate;
    }
    if (LiftIsFunctional == FALSE) // Remember to keep this in while changing effects.
    {
        print(s:"Doesn't work...yet."); // feel free to change all the stuff inside of these conditions
    }
    else
    {
        delay(16);
        Floor_MoveToValue(2,12,232);
    }
}

// The original code. Fixed it for ya.
// script 1 (void)
//    {
//        if (gametype()==GAME_NET_DEATHMATCH){
//            terminate;
//            }
//
//        lift1 = 1 ;
//        changecamera(1,1,0);
//        delay(16);
//        Floor_MoveToValue(2,12,232);
//        print(s:"The lift is now functional");
//        delay(160);
//        changecamera(0,0,0);
//        }

 

Fixed.rar

 

PS: Nice wad. It looks really good.

Share this post


Link to post
  • 0

You did it mate! I had to change a function with some values but you hit the jackpot! very well done indeed.

Thanks for your time and support.

This issue is now fixed 👍

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
×