Difference between revisions of "while"

From Bohemia Interactive Community
Jump to navigation Jump to search
Line 18: Line 18:
 
   
 
   
 
|x1= <code>[[while]] {a<b} '''[[do]]''' {a<nowiki>=</nowiki>a+1} </code>
 
|x1= <code>[[while]] {a<b} '''[[do]]''' {a<nowiki>=</nowiki>a+1} </code>
|x2=A practical example: Repair all members of a group to such a level that they are able to stand up: <code><nowiki>{</nowiki><br>&nbsp;&nbsp;while <nowiki>{</nowiki>([[not]] [[canStand]] _x) [[and]] ([[alive]] _x)<nowiki>}</nowiki> [[do]] <nowiki>{</nowiki><br>&nbsp;&nbsp;&nbsp;&nbsp;_x [[setDammage]] ([[getDammage]] _x) - 0.01;<br>&nbsp;&nbsp;<nowiki>};</nowiki><br><nowiki>}</nowiki> [[forEach]] units [[group]] unitname; </code> |= Example 2____________________________________________________________
+
|x2=A practical example: Repair all members of a group to such a level that they are able to stand up: <code><nowiki>{</nowiki><br>&nbsp;&nbsp;[[while]] <nowiki>{</nowiki>([[not]] [[canStand]] _x) [[and]] ([[alive]] _x)<nowiki>}</nowiki> [[do]] <nowiki>{</nowiki><br>&nbsp;&nbsp;&nbsp;&nbsp;_x [[setDammage]] ([[getDammage]] _x) - 0.01;<br>&nbsp;&nbsp;<nowiki>};</nowiki><br><nowiki>}</nowiki> [[forEach]] [[units]] [[group]] unitname; </code> |= Example 2____________________________________________________________
  
 
| [[Control Structures]], [[waitUntil]] |= See also
 
| [[Control Structures]], [[waitUntil]] |= See also

Revision as of 14:46, 3 August 2013

Template:Command

Notes

Posted on May 14, 2008
Kronzky
The boolean code that's used to evaluate the while condition can be preceded by code that executes a regular command.
e.g. while {_a=_a+1; _a<10} do {...}
Posted on January 2, 2012
Lucky44
Different than in IF statements, the condition in a WHILE loop can use curly braces not parentheses, unless it has multiple conditions, as shown above. So this will be a problem: while (variable1 == "wait") do... But this will work: while {variable1 == "wait"} do...

Bottom Section