• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Is there any real difference using if/then multi?

Status
Not open for further replies.
Level 9
Joined
Nov 4, 2007
Messages
933
I find if/then multi useful when you have varying conditions that will carry out different actions depending on which one is met, whereas if/then/else is more useful if you have only one set of conditions that need to be met, and have the else always be fired if they are not.
 
I'd just script conditions myself, it's easier that way.
This what if then else conditions look like in .Galaxy.
JASS:
lv_u = EventUnit(); //EventUnit() is the same thing as TriggerUnit() from vJass (Warcraft III)
if (UnitGetType(lv_u) == "sheep") {
    DebugMsg(StringToText("Bawww!")); //DebugMsg is a custom function I made that displays "Debug: " in red then the line of text you give as a parameter in the function.
} else if (UnitGetType(lv_u) == "dog") {
    DebugMsg(StringToText("Grrrrowl!"));
} else {
    DebugMsg(StringToText("This ain't any animal I've ever heard of o.O"));
}
Since I'm showing off random .Galaxy script examples I might as well show you how a loop is done liek a pro too.
JASS:
lv_i = 1;
while (lv_i <= gv_userPlayersCount) {//gv_userPlayersCount is a constant global variable that is equal to the number of players in the map I made up. This is going to loop until lv_i is equal to my constant.
    gf_DebugMsg(IntToText(lv_i)); //If gv_userPlayersCount is 14; this'll output 14 debug messages counting from 1 to 14.
    lv_i += 1; //Increments the local integer variable "i" by 1 each time it loops.
}

I should probably do a .Galaxy for n00bs tutorial and submit it here... there's not a lot of SCII tutorials at all right now. Hmmmmmm...
 
Level 5
Joined
Jul 10, 2010
Messages
124
if/then/else fires one set of actions if a specific condition is met, and another set of actions under ALL other possible conditions

if/else/if will only fire a set of actions that match a set of conditions, there is no default behavior if none of your listed conditions are met

so think of if/then/else as an evaluation of a single true/false

and if/else/if as an evaluation of multiple true/false in a row
 
Status
Not open for further replies.
Top