Tags: bar modding, tweakdefs, buildoptions, grid keys, modOptions, unitdefs, beyond all reason modding

BAR TweakDefs: Required Subtables and Build Option Visibility

Why build options fail to appear in grid mode, which subtables tweakdefs need, and checking modOptions before using them.

Grid versus legacy build panels

Build options added through tweakdefs show up in legacy mode but disappear on the grid build panel. The grid menu organizes units into categories, so a new build option needs a valid category assignment to appear anywhere. Check the respective unit classification — combat, support, economy — and make sure the builder's grid category matches. The legacy build panel places everything in a flat list, which is why options show there even when the grid mapping is broken.

Required subtables

New tweakdefs fail silently when expected subtables don't exist. The critical ones: buildoptions, customparams, weapondefs, and weapons. A unit that lacks a buildoptions table entirely causes table.insert(ud.buildoptions, ...) to throw an error that kills the rest of the script. Always check that subtables exist before inserting into them.

Checking modOptions safely

A common mistake involves using modOptions.experimentalExtraUnits without first verifying that modOptions actually exists. The modoptions table arrives from the lobby host configuration, and in single-player or certain lobby types it may be nil. Guard the check with a simple Lua conditional: if UnitDefs["corprint"] then — if the unit exists, proceed. This pattern avoids crashes when the modoptions layer isn't initialized.

Unit existence checks also depend on the filepath and mod package name. Units from mods use namespaced identifiers that differ from core BAR unit names.

Getting started with syntax

New modders should look at existing tweakdef templates before writing from scratch. The local function pattern used across the BAR Tweaks repository shows correct subtable initialization, modOptions wrapping, and build table manipulation in working code. Reading one solid example saves hours of debugging syntax errors.

Creed of Champions

Creed of Champions runs a cooperative BAR environment where learning gets supported, not punished. Players who join find teammates willing to share knowledge across skill levels.

[Crd] Before discovering Creed, I was thinking the only thing that separates BAR from the perfect RTS is a friendly and safe social environment for new players to learn and feel included.
Advertisement