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

how does this script work?

Recommended Posts

script 1 (int sw1, sw2, sw3)
{
// If all three switches have been thrown,
// then activate the radiation leak.
if (sw1 && sw2 && sw3)
Sector_SetDamage (1, 50, MOD_LAVA);

// Turn off the radiation leak.
else
Sector_SetDamage (1, 0, MOD_WATER);
}

i saw this off the zdoom wiki tutorials my question/what i dont get is how does this script work as sw1 , sw2 , sw3 isnt a tag so how would this work?

thanks

Share this post


Link to post

"sw1, sw2, sw3" are arguments of the script. When the script is called, it's always called with specific values as arguments. "sw1, sw2, sw3" within the script will be substituted by these specific values. "if (sw1 && sw2 && sw3)" means "if sw1 is a non-zero value, and sw2 is a non-zero value, and sw3 is a non-zero value, then...".

Share this post


Link to post

ok i see what ur saying like when it says sw1 it looks for sw1 tag if its not zero but what im saying is how does it know what sw1 is i mean there could be 5 switches how does it know which one is sw1?

Share this post


Link to post

Arguments are just numbers. They do not have any inherent relation with tags, nor with switches or any other objects within the map. Their values depend on the values with which the script was called.

When you have a script:

script 1 (int sw1, sw2, sw3) {
  ...
}
And you call it for example this way:
ACS_Execute(1,0,15,29,200);
Then an instance of the script will start running, and in this instance, "sw1" will have value "15", "sw2" will have value "29", and "sw3" will have value "200".

The names "sw1, sw2, sw3" are completely arbitrary. You could have named the arguments anything you wanted, for example "x, y, z".

Share this post


Link to post

ok so im geting that the script will only do something when something happens that makes all 3 sw's = 0 my final question is how would this make a door requiring the use of 3 switches as its not linked to anything on map?

thanks youve been some good help

Share this post


Link to post

I would do it this way instead:

#include "zcommon.acs"

int countSwitches = 0;

script 1 (void) {
  countSwitches++;
  if(countSwitches==3) { Door_Open(...); }
}
Make script 1 be executed (non-repeatably) by each of the 3 switches. No arguments are needed here at all.

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
×