Looking up unit build options and names in BAR widgets

Finding a unit's buildoptions list and matching code names to in-game display names requires knowing where to look in UnitDefs and the language files.

Tags: beyond all reason, widgets, buildoptions, unitdefs, lua, modding

Getting buildoptions from UnitDefs

If you have a unit's defid, pull its buildoptions with UnitDefs.defid.buildoptions. Without the defid, use an engine call to resolve it first. Some widget authors cache the units they care about in a local table during Initialize to avoid repeated lookups.

Matching unit codes to display names

UnitDefs uses internal names like armafus and corckfus. The mapping from code names to in-game display names lives in the language JSON files on the BAR GitHub repo. Opening the units.json file under language/en shows both sides of every mapping.

Filtering by defid ranges

Units fall into defid ranges. Range 100-199 covers a particular tier or faction. Iterating over pairs of UnitDefs and checking GetUnitDefID lets you filter by range. Exclude specific units like commanders by name comparison before processing.

Creed of champions

Knowing your tools gives you an edge in any RTS. Creed of Champions brings together players who put in the time to understand the game deeper. Friendly people, serious play.

[Crd] It is so easy to get on with everyone and there is zero toxicity. Just fun games of BAR which can have quite a toxic community usually.
Advertisement