Switch: Difference between revisions
Jump to navigation
Jump to search
Hendricks266 (talk | contribs) No edit summary |
Hendricks266 (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
switch <gamevar> | switch <gamevar> | ||
case <constant> | case <constant>: | ||
<do something> | <do something> | ||
[[break]] | |||
case <constant> | case <constant>: | ||
<do something> | <do something> | ||
break | break | ||
[[ | default | ||
<do something> | |||
break | |||
endswitch | |||
The '''default''' keyword works like an [[ifvarn]] statement, just like '''case''' works like an [[ifvare]] statement. | |||
Caution: ''Nested switches do not work because of the way the CON compiler compiles them''. A workaround is to put the nested switch in a seperate state, and call that state from inside the first switch. | Caution: ''Nested switches do not work because of the way the CON compiler compiles them''. A workaround is to put the nested switch in a seperate state, and call that state from inside the first switch. |
Revision as of 13:36, 30 September 2006
The switch statement in con is similar to that in C.
switch <gamevar> case <constant>: <do something> break case <constant>: <do something> break default <do something> break endswitch
The default keyword works like an ifvarn statement, just like case works like an ifvare statement.
Caution: Nested switches do not work because of the way the CON compiler compiles them. A workaround is to put the nested switch in a seperate state, and call that state from inside the first switch.
Also, putting extra break statements inside a case argument will cause a lot of errors. Again, the workaround is to put the commands that need to be seperated in another state, along with the break.