Skip to content

Fetch

A radar sees around itself, query sees an area. Fetch sees everything a team has on the map

tick 0
Fetch0
typeresultteamindexextra
Fetch1
typeresultteamindexextra
Fetch2
typeresultteamindexextra
Fetch3
typeresultteamindexextra
Fetch4
typeresultteamindexextra
Sensor5
=
in
Fetch6
typeresultteamindexextra
Sensor7
=
in
Stop8
@counter0number
ourUnitsnullnull
ourBuildingsnullnull
turretsnullnull
theirUnitsnullnull
corenullnull
copperInCorenullnull
firstUnitnullnull
firstKindnullnull
fetch unitCount ourUnits @sharded 0 0
fetch buildCount turrets @sharded 0 @duo
fetch core core @sharded 0 0

Three questions to the map: how many units we have (two), how many duos (also two) and where the core is. Distance has nothing to do with it — fetch sees the whole map at once.

Field What is in it
first what to get: unit, build, core or their counters
second where to put it
third the team
fourth the index in the list, counting from zero
fifth a type filter: a block for build, a unit type for unit

The kinds split in half: half give the object itself by index, half give how many there are.

Gives an object Gives a number
unit unitCount
build buildCount
core coreCount
player playerCount

Hence the usual shape of a walk: ask for the count first, then go through the indices.

fetch unitCount amount @sharded 0 0
set index 0
fetch unit unit @sharded index 0
sensor health unit @health
op add index index 1
jump 2 lessThan index amount

The list runs in order of appearance: whatever was built or created earlier comes earlier in the list. The indices in it are attached to nobody: let the unit with index 3 die and everything after it shifts by one.

radar query fetch
where it looks around a building in an area of the map across the whole map
what it gives one everybody in the area one by index, or a count
who can use it everyone a world processor a world processor
finds buildings no yes yes

fetch is the only way to ask “how many units does the enemy have at all” or “where is their core” without walking the map tile by tile.

Unofficial fan project, not affiliated with Anuke. Mindustry sprites, fonts and translations © Anuke, used under GPL-3.0; Fira Code under OFL-1.1. Site code is GPL-3.0.