TrainUnit¶
Request unit production from one or more owned buildings.
TrainUnit(buildings, buildingType, unitType, count?) ·
TrainUnitTracked(buildings, buildingType, unitType, count?)
Inputs: buildings is one owned building Object or a dense array.
buildingType and unitType are integer IDs in 0..32767. Optional count
is an integer in 1..32767 and defaults to 1.
Output: TrainUnit returns true for queue admission, otherwise false.
TrainUnitTracked returns accepted, receipt. Neither confirms production; inspect
the live queue before issuing a dependent request.
Errors: Wrong Lua argument types raise an argument error. Invalid IDs or count
reject admission; tracked calls report invalid-type or invalid-count. Invalid
buildings, unavailable native layout, or an inactive session can also reject the
request, including after admission.
Example:
local accepted = TrainUnit(producer, buildingType, unitType, 1)
if not accepted then LogWarn("Training request was not queued") end
Here producer is a freshly queried owned building and the type IDs describe
that building and the requested unit. Use named constants when available.