Home   Help Search Login Register  

Author Topic: if then else if then else if then else  (Read 781 times)

0 Members and 1 Guest are viewing this topic.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
if then else if then else if then else
« on: 05 Dec 2002, 21:23:28 »
I was wondering. Can you nest "if () then {} else {}" commands...Like so? If noone knows I'll try it later. If you can it would be good info to have on this board for others benefit.
 
Code: [Select]
if () then {} else {if () then {} else {if () then {} else {if () then {} else {}}}}
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline XCess

  • Former Staff
  • ****
Re:if then else if then else if then else
« Reply #1 on: 08 Dec 2002, 15:34:59 »
yes

? = if
: = then
you have to put a line underneath for else

e.g
?(num <= 10 ) : goto"under"
goto"over"

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:if then else if then else if then else
« Reply #2 on: 08 Dec 2002, 23:47:52 »
yes TL, you can.
And you can use IF...then...else (or if then [{},{}] in places where you can't use ? : (like functions).
Dinger/Cfit

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:if then else if then else if then else
« Reply #3 on: 09 Dec 2002, 06:29:21 »
Yeah I've been using the if-then-else and while-do commands in my scripts lately. They are extremely handy.

I just was wondering if you could nest them so that you could do a line like so.

if (!alive soldier1) then {hint "soldier1 died"} else {if (!alive soldier2) then {hint "soldier2 died"} else {if (!alive soldier3) then {hint "soldier3 died"} else {if (!alive soldier4) then {hint "soldier4 died"}}}}

I finally got around to trying it and it works.

Thanks Dinger.

"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.