Forum Archive. A read-only snapshot of the Warfare Incorporated forums (2003–2020), preserved for historical purposes.  ·  warfareincorporated.com
Warfare Incorporated Forum

What is a switch
Author Message
White_Knight
Very Active User


Joined: 22 Mar 2005
Posts: 142
Location: Im my House
 Post Posted: Sun May 15, 2005 6:51 am  Post subject: What is a switch

:arrow: WHAT A !#&%$ 'n' HELL is a SWITCH and what is it for.


please answer i really need to know
my depends of it !!! :D :D
PhillipEarl
Mega-Poster


Joined: 12 Jan 2004
Posts: 329
Location: Charlotte, NC
 Post Posted: Tue May 17, 2005 6:36 am  

A switch is a two-part condition in the Mission Editor script - it is either "on" or "off."

To set up a switch, first you need to create the switch - there is a menu option for switches just like there is one for Triggers. Once the menu option is selected, it brings up a pop-up menu in ME where you can create and edit triggers.

Once that's done, you'll need a trigger (or set of triggers) that interract with the switch.

For example, say you need a particular unit group to spawn after a certain ammount of time has passed in a mission, say only two minutes. First you would create a switch - the switch can be named whatever you want, but let's call it "Spawn."

Now, in your mission loaded trigger you'll want to make sure the switch is set to off. In your actions window, select New Action and you'll see "Set Switch" in the actions menu. Set the switch to off.

Next, you'll need to write a trigger that changes the switch to on. It should look something like this:

Condition:
Elapsed time is at least 120 seconds

Action:
Set switch "Spawn" on

Now you need a trigger that defines what happens when the switch is on:

Condition:
Switch "Spawn" is on

Action:
Spawn unit group
Preserve trigger

So why use a switch, instead of just spawning the unit group directly once the elapsed time condition is met? Simple: so you can turn the switch off later. Otherwise, the unit group would continually spawn, and if the mission was focused on eliminating that group, it would never end.

Switches are especially useful for simultaneously turning on multiple effects that have different conditions, or turning on one effect that requires multiple triggers. Think of them as mission scripting choke points.

Hope that helps! If you need any further help, or help with achieving a specific effect, feel free to ask!
White_Knight
Very Active User


Joined: 22 Mar 2005
Posts: 142
Location: Im my House
 Post Posted: Tue May 17, 2005 8:33 am  Post subject: THANKS :D :D :D

:D Thanks your the best, ive already developed 3 maps and i havent used any switch yet you now why (it was cuz of my stupidity).
guitarist809
Veteran Member


Joined: 08 Jan 2005
Posts: 1234
 Post Posted: Tue May 17, 2005 5:36 pm  

Sort of like the IF statment

if (vara != varb)
{
echo "wdf?";
}
else
{
echo "dunno...";
}

Thats using PHP
Verdagon
Veteran Member
Joined: 05 Oct 2003
Posts: 1047
Location: San Luis Obispo, CA
 Post Posted: Sat May 28, 2005 1:59 pm  

On the subject of switches... What does a switch start out as: random or off?
guitarist809
Veteran Member


Joined: 08 Jan 2005
Posts: 1234
 Post Posted: Sat May 28, 2005 3:52 pm  

I think it starts off as 'NULL' or nothing. I think you have to automatically set a switch as 'no' or 'yes'.
dancer402
Mega-Poster


Joined: 12 Feb 2005
Posts: 294
Location: Monument CO
 Post Posted: Wed Jun 01, 2005 10:39 am  

ya i bet it is null
PhillipEarl
Mega-Poster


Joined: 12 Jan 2004
Posts: 329
Location: Charlotte, NC
 Post Posted: Wed Jun 01, 2005 12:39 pm  

In my experience, a switch that isn't specified always starts out as off by default. A pvar always starts out as 0 unless you specify otherwise.

Still, I always set all switches and pvars in the mission loaded trigger. Better to be sure.
guitarist809
Veteran Member


Joined: 08 Jan 2005
Posts: 1234
 Post Posted: Wed Jun 01, 2005 12:57 pm  

Alright.
dancer402
Mega-Poster


Joined: 12 Feb 2005
Posts: 294
Location: Monument CO
 Post Posted: Thu Jun 02, 2005 6:37 am  

I always set my switches to off at the start just to be safe.
guitarist809
Veteran Member


Joined: 08 Jan 2005
Posts: 1234
 Post Posted: Thu Jun 02, 2005 10:10 pm  

same here, I just noticed im in 2nd place in all the top ten posters on this forum :)