Script Argument

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
ryguy147
Posts: 57
Joined: Sat Jul 02, 2011 2:36 pm
Location: Behind a computer

Script Argument

Post by ryguy147 »

I have a question about scripts.

How can you change the effect of a script with a script argument?

For example, I have a script that displays a message. I make a linedef that uses script execute. I want to run the same script, it will be different for whatever line is crossed. If i set one linedef action to script argument 1 = 1, and another to script argument 1 = 2. How do I make that affect the script???
User avatar
chopkinsca
Posts: 1325
Joined: Thu Dec 11, 2003 5:03 pm

Re: Script Argument

Post by chopkinsca »

Code: Select all

script 1 (int variableyouwant) {
     if(variableyouwant == 1) {
        //do stuff
    }
    if(variableyouwant == 2) {
        //do stuff
    }
}
And so on.
User avatar
ryguy147
Posts: 57
Joined: Sat Jul 02, 2011 2:36 pm
Location: Behind a computer

Re: Script Argument

Post by ryguy147 »

chopkinsca wrote:

Code: Select all

script 1 (int variableyouwant) {
     if(variableyouwant == 1) {
        //do stuff
    }
    if(variableyouwant == 2) {
        //do stuff
    }
}
And so on.
So if the argument was 1 and i did this...

Code: Select all

script 1 (int variableyouwant) {
     if(variableyouwant == 1) {
        print(s:"Good!");
    }
    if(variableyouwant == 2) {
        print(s:"Bad!");
    }
}
...it would say "good"?
User avatar
ryguy147
Posts: 57
Joined: Sat Jul 02, 2011 2:36 pm
Location: Behind a computer

Re: Script Argument

Post by ryguy147 »

OK, having some problems. I'm making a thing that uses HUD message that tells you where you are. The code:

Code: Select all

script 100 (int location)
{
    if(location==1)
    {
        place = "Base";
    }
    if(location==2)
    {
        place = "Outside Base";
    }
//checks that PDA use is allowed
    if(PDA==99);
    {
        While(TRUE)
        {
        HudMessage(s:"Location: ",
        s: place;
        HUDMSG_PLAIN, 1, CR_GOLD, 0.98, 0.02, 1.0);
        Delay(25);
        } 
    }
}
There are some linedefs that run script 100, with script argument 1 = 1, script argument 2 = 2, etc.

But the location appears when I cross that argument 2 line (at that point, it isn't allowed yet), and doesn't change. (says base)

What am I doing wrong?
User avatar
chopkinsca
Posts: 1325
Joined: Thu Dec 11, 2003 5:03 pm

Re: Script Argument

Post by chopkinsca »

As you have it, script 100 runs and gets stuck in the while loop, preventing the script from being ran again normally. ACS_ExecuteAlways would solve the problem, but create a new problem, everytime you execute the script you add a loop that the script is stuck in. Separate the script into two parts. One for changing the 'place' variable, and the second for displaying the place message.
User avatar
ryguy147
Posts: 57
Joined: Sat Jul 02, 2011 2:36 pm
Location: Behind a computer

Re: Script Argument

Post by ryguy147 »

chopkinsca wrote:As you have it, script 100 runs and gets stuck in the while loop, preventing the script from being ran again normally. ACS_ExecuteAlways would solve the problem, but create a new problem, everytime you execute the script you add a loop that the script is stuck in. Separate the script into two parts. One for changing the 'place' variable, and the second for displaying the place message.
Thanks for that, I'll try.
Locked

Return to “Editing (Archive)”