Items: take and drop
A unit is a portable storage slot: one kind of item, a few places and a compulsory delay between trips
ucontrol itemTake container1 @copper 10 0 0The poly takes copper out of the store: cargo grows, inStore shrinks. Once the unit is
full — and a poly has thirty places — taking stops changing anything.
| Field | itemTake |
itemDrop |
|---|---|---|
| second | where from: a building | where to: a building |
| third | which item | how many to hand over |
| fourth | how many to take | — |
The difference in fields is no accident: only one kind of item can be taken, and which one has to be said; what a unit hands over is whatever it has — there is nothing to choose from.
Three rules of transfer
Section titled “Three rules of transfer”Only up close. Transfer works within about six tiles of the building — roughly as far as
a player can drag things by hand. The unit is brought in with move first, and only then given
the transfer order.
No more often than once every one and a half seconds. Ninety ticks pass between one unit’s two transfers. An order given sooner simply does nothing: no error, no half transfer.
Only your own. Another team’s store will not give to a unit and will not accept from it — the order silently does nothing.
A unit carries one kind of item
Section titled “A unit carries one kind of item”Unlike a store, a unit has one cargo slot: it carries copper or graphite, but not both at once. Take copper and then try to take graphite, and there will be no graphite.
| Property | What it gives |
|---|---|
@totalItems |
how much it carries in total |
@firstItem |
what exactly it carries: @copper, @graphite or emptiness |
@itemCapacity |
how much fits: 30 on a poly, 20 on a mono, 60 on a mega |
A full trip
Section titled “A full trip”Here is a whole ferry program. It looks at its cargo and decides where to fly: empty — to the store for copper, full — to the recipient.
ubind @polysensor cargo @unit @totalItemsjump 6 greaterThanEq cargo 30ucontrol move 5 4 0 0 0ucontrol itemTake container1 @copper 30 0 0enducontrol move 15 4 0 0 0ucontrol itemDrop container2 30 0 0 0Three trips and ninety copper have moved into the second store. Note that there is no within
and no waiting here at all: the transfer order is issued every iteration and fires by itself as
soon as the unit arrives and the delay has passed. Such a ferry is shorter and more reliable
than a program that honestly waits for arrival.
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.