Whilevarn

From EDukeWiki
Revision as of 09:26, 27 June 2007 by 66.154.95.166 (talk) (New page: whilevarn <gamevar> <value> { code to execute } Executes the code in the curly braces as long as <gamevar> does not equal <value>. This is a simple while loop. Caution: Poor execution or...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

whilevarn <gamevar> <value> { code to execute }

Executes the code in the curly braces as long as <gamevar> does not equal <value>. This is a simple while loop.

Caution: Poor execution or endless loops will cause your game to close without error or simply stall and crash!

An example:

gamevar TEMP 0 2
gamevar RANDX 0 2
gamevar RANDY 0 2
gamevar RANDZ 0 2

state troopspawnstate
    setvar TEMP 0
    whilevarn TEMP 10
    {
        randvar RANDX 2048
        mulvarvar RANDX TEMP
        randvar RANDY 2048
        mulvarvar RANDY TEMP
        randvar RANDZ 2048
        mulvarvar RANDZ TEMP
       
        espawn EXPLOSION2          // Spawn an explosion at a random location
        setactor[RETURN].x RANDX   // that gets progressively further away the
        setactor[RETURN].y RANDY   // longer that the code executes.
        setactor[RETURN].z RANDZ

        addvar TEMP 1
    }
ends

. . .

state troopcode
. . .

ifaction ATROOPHIDE             // Execute the code while the Liztroop
    state troopspawnstate       // Captain is teleporting in/out.
ifaction ATROOPREAPPEAR
    state troopspawnstate

. . .
ends