Category:If conditions: Difference between revisions
Jump to navigation
Jump to search
Helixhorned (talk | contribs) m more braces to really make sense |
Helixhorned (talk | contribs) simplify dangling-else example, upper->outer |
||
Line 8: | Line 8: | ||
In a cascade of multiple ''if''s followed by an ''else if'', the latter is bound to the ''' | In a cascade of multiple ''if''s followed by an ''else if'', the latter is bound to the '''outermost''' of the former ''if''s. Thus, the following code | ||
[[redefinequote]] 114 NOPE | [[redefinequote]] 114 NOPE | ||
[[ifvare]] 0 1 [[ifvare]] 0 0 [[redefinequote]] 114 ONE | [[ifvare]] 0 1 [[ifvare]] 0 0 [[redefinequote]] 114 ONE | ||
[[else]] | [[else]] [[redefinequote]] 114 TWO | ||
is equivalent to this explicitly-braced one: | is equivalent to this explicitly-braced one: | ||
Line 19: | Line 19: | ||
[[ifvare]] 0 1 { [[ifvare]] 0 0 [[redefinequote]] 114 ONE | [[ifvare]] 0 1 { [[ifvare]] 0 0 [[redefinequote]] 114 ONE | ||
} | } | ||
else | else [[redefinequote]] 114 TWO | ||
and NOT this one, as with C-derived programming languages, | and NOT this one, as with C-derived programming languages, | ||
Line 26: | Line 26: | ||
[[ifvare]] 0 1 { [[ifvare]] 0 0 { [[redefinequote]] 114 ONE | [[ifvare]] 0 1 { [[ifvare]] 0 0 { [[redefinequote]] 114 ONE | ||
} | } | ||
else | else [[redefinequote]] 114 TWO | ||
} | } | ||
Revision as of 10:25, 13 June 2012
If conditions evaluate the specified statement, and run code based on the returned value of the evaluation. If conditions are boolean (true or false), and may be strung together.
Example code:
ifdead { spawn BLOODPOOL killit }
If conditions may be used in conjunction with an else.
In a cascade of multiple ifs followed by an else if, the latter is bound to the outermost of the former ifs. Thus, the following code
redefinequote 114 NOPE ifvare 0 1 ifvare 0 0 redefinequote 114 ONE else redefinequote 114 TWO
is equivalent to this explicitly-braced one:
redefinequote 114 NOPE ifvare 0 1 { ifvare 0 0 redefinequote 114 ONE } else redefinequote 114 TWO
and NOT this one, as with C-derived programming languages,
redefinequote 114 NOPE ifvare 0 1 { ifvare 0 0 { redefinequote 114 ONE } else redefinequote 114 TWO }
and quote 114 contains the string 'TWO' after its execution.
Pages in category "If conditions"
The following 90 pages are in this category, out of 90 total.
I
- Ifa
- Ifaction
- Ifactioncount
- Ifactor
- Ifactornotstayput
- Ifae
- Ifai
- Ifand
- Ifangdiffl
- Ifawayfromwall
- Ifb
- Ifbe
- Ifboth
- Ifbulletnear
- Ifcansee
- Ifcanseetarget
- Ifcanshoottarget
- Ifceilingdistl
- Ifclient
- Ifcount
- Ifdead
- Ife
- Ifeither
- Iffloordistl
- Ifg
- Ifgapzl
- Ifge
- Ifgotweaponce
- Ifhitspace
- Ifhitweapon
- Ifinouterspace
- Ifinspace
- Ifinwater
- Ifl
- Ifle
- Ifmove
- Ifmultiplayer
- Ifn
- Ifnosounds
- Ifnotmoving
- Ifonwater
- Ifor
- Ifoutside
- Ifp
- Ifpdistg
- Ifpdistl
- Ifphealthl
- Ifpinventory
- Ifplayersl
- Ifrespawn
- Ifrnd
- Ifserver
- Ifsound
- Ifspawnedby
- Ifspritepal
- Ifsquished
- Ifstrength
- Ifvar conditions
- Ifvara
- Ifvarae
- Ifvarand
- Ifvarb
- Ifvarbe
- Ifvarboth
- Ifvare
- Ifvareither
- Ifvarg
- Ifvarge
- Ifvarl
- Ifvarle
- Ifvarn
- Ifvaror
- Ifvarvara
- Ifvarvarae
- Ifvarvarand
- Ifvarvarb
- Ifvarvarbe
- Ifvarvarboth
- Ifvarvare
- Ifvarvareither
- Ifvarvarg
- Ifvarvarge
- Ifvarvarl
- Ifvarvarle
- Ifvarvarn
- Ifvarvaror
- Ifvarvarxor
- Ifvarxor
- Ifwasweapon
- Ifxor