Difference between revisions of "Manual:DIL Manual/foreach()"
Jump to navigation
Jump to search
(XML import) |
(XML import) |
||
| Line 1: | Line 1: | ||
| + | <span id="forea"></span> | ||
| + | '''foreach:''' | ||
| + | Foreach is an easy way to process all the units in the | ||
| + | local environment relative to the 'self' executing the | ||
| + | foreach. Foreach takes care of creating a list of local | ||
| + | units, and of securing them. You can use both break and | ||
| + | continue in a foreach statement. The unit executing the | ||
| + | foreach ('self') is always a part of the foreach. | ||
| + | |||
| + | It is important to understand that the units in the local | ||
| + | environment are relative to the 'self' executing the foreach. | ||
| + | |||
| + | '''Example:''' | ||
| + | This foreach is copied onto the spell caster, and hence all units | ||
| + | relative to the spell caster (i.e. self) are processed in the foreach. | ||
| + | Assume that it was executed on the spell caster's staff, then all units | ||
| + | found would be relative to the staff, i.e. the spell caster's inventory. | ||
| + | <nowiki> | ||
| + | ... | ||
| + | foreach (UNIT_ST_PC|UNIT_ST_NPC, u) | ||
| + | ...</nowiki> | ||
<span id="forea"></span> | <span id="forea"></span> | ||
'''foreach:''' | '''foreach:''' | ||
| Line 23: | Line 44: | ||
... | ... | ||
foreach (UNIT_ST_PC|UNIT_ST_NPC, u) | foreach (UNIT_ST_PC|UNIT_ST_NPC, u) | ||
| − | + | ...</nowiki> | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 22:31, 4 December 2025
foreach:
Foreach is an easy way to process all the units in the
local environment relative to the 'self' executing the
foreach. Foreach takes care of creating a list of local
units, and of securing them. You can use both break and
continue in a foreach statement. The unit executing the
foreach ('self') is always a part of the foreach.
It is important to understand that the units in the local
environment are relative to the 'self' executing the foreach.
Example:
This foreach is copied onto the spell caster, and hence all units
relative to the spell caster (i.e. self) are processed in the foreach.
Assume that it was executed on the spell caster's staff, then all units
found would be relative to the staff, i.e. the spell caster's inventory.
...
foreach (UNIT_ST_PC|UNIT_ST_NPC, u)
...
foreach:
Foreach is an easy way to process all the units in the
local environment relative to the 'self' executing the
foreach. Foreach takes care of creating a list of local
units, and of securing them. You can use both break and
continue in a foreach statement. The unit executing the
foreach ('self') is always a part of the foreach.
It is important to understand that the units in the local
environment are relative to the 'self' executing the foreach.
Example:
This foreach is copied onto the spell caster, and hence all units
relative to the spell caster (i.e. self) are processed in the foreach.
Assume that it was executed on the spell caster's staff, then all units
found would be relative to the staff, i.e. the spell caster's inventory.
...
foreach (UNIT_ST_PC|UNIT_ST_NPC, u)
...