ReferenceVerse
Iterate An Array V6
iterate an array v6
Updated
iterate-an-array-v6 in ~90 seconds.One paddle into the dappled mangrove channel and suddenly three hidden chests burst open, raining a triple loot drop onto your canoe.
That rapid-fire drop happens because we're iterating over an array of item granters, letting a single for loop fire every device in the cache.
We grab the first player, then our for loop acts as a conveyor, pulling each granter from the array and calling GrantItem to hand out the gear.
Reach for a for loop whenever you need to run the exact same action across a whole fleet of devices or players.
mangrove_cache := class(creative_device):
@editable
CacheGranters : []item_granter_device = array{}
OnBegin<override>()<suspends>:void =
Players := GetPlayspace().GetPlayers()
if (Lucky := Players[0]?):
for (Granter : CacheGranters):
Granter.GrantItem(Lucky)
Build your own lesson with iterate-an-array-v6
Generate a personalized, compile-checked lesson grounded in this exact reference.
Build a lesson →