What BAR gadgets cannot do, how to validate buildoptions tables in Lua, and what unit data actually reaches your modding code.
Tags: bar modding, gadgets limitations, buildoptions cleanup, unitdefs lua, builder property
Gadgets in BAR sit on top of the game but cannot rewrite everything. You cannot change sight lines through gadgets. You cannot edit buildoptions or set builder equal to true on an existing unit definition through gadget code alone. These properties are locked when the game loads unit definitions.
Lua passes UnitDefs and Spring to modding code. That is the access you get. No single unit definition object is handed to you individually. You work with the full table or you do not work with it at all.
A practical pattern for scanning unit definitions and removing broken build menu entries goes like this: iterate over pairs(unitDefs) and grab the buildoptions table using def.buildOptions or def.buildoptions. Loop through the options with ipairs(). Check if each option exists as a key in unitDefs. If not, mark the index for removal.
After scanning all options, remove bad entries in reverse order using table.remove(). Removing in reverse prevents index shifting from breaking your removal loop. Track how many entries you removed so you can log the results cleanly.
Invalid buildoptions do not always trigger errors. Sometimes they just create empty menu slots or missing entries that confuse players testing your mod. Running a buildoptions validation script catches these issues before release.
The same scanning pattern works for other unitdef tables. Swap out badOptions and buildoptions for whatever subtable you need to validate. The logic stays the same: iterate, verify existence, mark bad indices, remove in reverse.
Attention to detail separates clean mods from broken ones. That same discipline matters in competitive BAR play. Creed of Champions builds teams around players who bring precision and a cooperative attitude. Excellence in game, teamwork, and attitude. Training sessions, organized team matches, and a community that values improvement over ego. Worth checking out if that aligns with how you want to play.
[Crd] The first and only community I have seen that actually holds up to its values. I have honestly not had a single bad experience here.