For: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Fox (talk | contribs)
No edit summary
Add note about conditional evaluation
Line 29: Line 29:
| '''range''' <num> || A range from 0 to the number specified.
| '''range''' <num> || A range from 0 to the number specified.
|}
|}
Unlike other loop forms, the conditional statement is ''not'' re-evaluated each iteration. For example, the following loop will log 1 through 10:
var i
var j 10
for i range j {
    add i 1 // only affects current iteration; log 1..10 instead of 0..9
    sub j 1 // same as above; effectively does nothing in this example
    al i
}


[[Category:EDuke32 specific commands]]
[[Category:EDuke32 specific commands]]

Revision as of 07:12, 15 July 2020

for <gamevar> <function> { [...] }
for <gamevar> <function> <value> { [...] }

Executes the code in the curly braces for every instance of the function specified, and <gamevar> stores the sprite/sector/wall/etc found in the current function.

For example, setting <function> to allsprites will execute the code for every sprite in-game, and the var specified in <gamevar> will be set to the sprite number of the current sprite it's on.

Functions

allsprites All actors/sprites in-game.
allsectors All sectors in the map.
allwalls All walls in the map.
activelights
lights
All active polymer lights.
drawnsprites Only the sprites currently being drawn.
spritesofsector<sectnum>
sprofsec<sectnum>
All sprites in the given sector.
spritesofstatus <statnum>
sprofstat <statnum>
All sprites with the given statnum.
wallsofsector <sectnum>
walofsec <sectnum>
The walls of the given sector.
loopofwall <wall num> All walls in the same loop of the given wall.
range <num> A range from 0 to the number specified.

Unlike other loop forms, the conditional statement is not re-evaluated each iteration. For example, the following loop will log 1 through 10:

var i
var j 10
for i range j {
    add i 1 // only affects current iteration; log 1..10 instead of 0..9
    sub j 1 // same as above; effectively does nothing in this example
    al i
}