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???
Script Argument
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.
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.
- chopkinsca
- Posts: 1325
- Joined: Thu Dec 11, 2003 5:03 pm
Re: Script Argument
Code: Select all
script 1 (int variableyouwant) {
if(variableyouwant == 1) {
//do stuff
}
if(variableyouwant == 2) {
//do stuff
}
}
Re: Script Argument
So if the argument was 1 and i did this...chopkinsca wrote:And so on.Code: Select all
script 1 (int variableyouwant) { if(variableyouwant == 1) { //do stuff } if(variableyouwant == 2) { //do stuff } }
Code: Select all
script 1 (int variableyouwant) {
if(variableyouwant == 1) {
print(s:"Good!");
}
if(variableyouwant == 2) {
print(s:"Bad!");
}
}
Re: Script Argument
OK, having some problems. I'm making a thing that uses HUD message that tells you where you are. The code:
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?
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);
}
}
}
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?
- chopkinsca
- Posts: 1325
- Joined: Thu Dec 11, 2003 5:03 pm
Re: Script Argument
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.
Re: Script Argument
Thanks for that, I'll try.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.