Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Alynn on Fri 14/11/2003 14:36:04

Title: Switch/Case statements
Post by: Alynn on Fri 14/11/2003 14:36:04
You think maybe you could place this in here... so many if statements gets on my nerves...

(using psudocode)
switch (inventory_Number){
   case 1: {Witty remark}
   case 2: {Smartass remark}
   case 3: {Correct item do stuff}
   case 4: {Make fun of the player for thinking that}
   case 5: {Kill the player (never use a fork on an electrical outlet)
   default: {Throw random gibberish on the screen}
}


So much nicer IMO... many if statements work the same, just not as easy to maintain... (would be nice if it would work for strings also)
Title: Re:Switch/Case statements
Post by: scotch on Fri 14/11/2003 14:40:12
It's been asked for a few times, I'd like it as there are many places in my code it would save large amounts of space, but you can always do it with if statements so CJ seems to want to work on other things instead, which is fine by me.
Title: Re:Switch/Case statements
Post by: Pumaman on Fri 14/11/2003 15:26:41
Yeah, it's a low priority feature since you can do it with "else if"s instead, but it would be nice, I agree.