Skip to content

QS0 while cmd

maybites edited this page Sep 12, 2022 · 1 revision

<while name="(string)" start="{expr}" repeat="{expr}" step="{expr})" >

###Simple Example

<while name="whileLoop" init="{:whilevar = 0}" condition="{whilevar lt 100}" next="{whilevar = (whilevar + 1)}">
    <if true="{whilevar lt 50}">
        <print>inside while below 50: {whilevar}</print>
        <else>
            <print>inside while above 50: {whilevar}</print>
        </else>
    </if>
</while>
<wait anim="whileLoop"/>

Attributes

  • name = if name is set, <while> will sends an anim-message once the loop has exited (condition == false). this message can be caught by a <wait anim="whileLoop"/> cmd.
  • init = if used, its {expr} is evaluated first. Usefull to create a local variable inside the loop.
  • condition = required. its {expr} has to be true (>= 1) to go into the loop
  • next = if used, its {expr} is evaluated after each loop. Useful to increment a local variable inside the loop.

Child Commands

Explained

the <while> cmd defines an loop like structure for an animation and works like 'while' or 'for' in classical languages

Notice

  • if a name-attribute is used, once the condition is false the node will send an anim-message to be caught by a <wait anim="whileLoop"/> node.
  • the init-attribute's expression {:whilevar = 0} sets the variable 'whilevar' to 0. the : at the beginning of the variable name indicates that if the variable doesn't exist yet, the script will create the 'whilevar' variable in the local variable scope. the <while> node (like the <anim> node) have a separate local variable scopes to the <que>. this way you can create variables that don't interfere with each other.
Clone this wiki locally