Getting bracket balance, table structure, and Lua syntax right when writing BAR tweakunits for unit and weapon modifications.
Tags: beyond all reason, tweakunits syntax, Lua brackets, modding errors, unit modifications
Every tweakunits entry is a Lua table. Tables nest inside tables. The closing bracket } ends a table level. Missing one or adding an extra one breaks the entire tweak. A tweakunits block typically needs the outer return table, the unit name table, and then nested field tables for things like damage or buildoptions.
A typical nested damage block looks like: damage = { default = 300, },. The outer brackets contain the damage fields, the default sits inside, and the trailing comma separates it from sibling fields like reloadtime.
A frequent mistake when testing tweaks: writing the inner content without the outer return table wrapper. The tweakunits loader expects a return statement with a complete table. Partial entries without the outer brackets get silently ignored or produce confusing partial results where some modifications apply and others do not.
If a tweak seems to partially work where certain units change but others do not, missing wrapper brackets is the first thing to check.
Unit definitions belong in tweakdefs while weapon definitions go in tweakunits. Mixing content between the two causes loader conflicts. All weapons in one channel and all units in the other keeps modifications organized and predictable.
Running a quick skirmish match validates whether a tweak works. If juggernauts still appear after modifying their availability, the tweak did not actually remove them. Checking the outer bracket structure and ensuring the return table wraps everything fixes most cases where modifications silently fail.
Debugging Lua brackets and table structures teaches attention to detail that carries over into actual matches. Players who understand the structure of unit definitions make better choices about unit composition and counter-play. A community that tolerates beginner mistakes helps people learn faster:
[Crd] Gaming actually fulfills a human purpose here - cooperation, mutual upbuilding, fun and striving for greatness together.