Common mistakes when writing tweakdefs in Beyond All Reason and how to avoid them, from missing subtables to explosion definitions.
Tags: modding, tweakdefs, unitdefs, lua, build options, explosions, custom params, beyond all reason
New tweakdefs fail when expected subtables are missing. The four subtables that cause the most problems are buildoptions, customparams, weapondefs, and weapons. If any of these are referenced inside a unit definition but left unset, the tweak silently breaks.
When working with tweakunits, the entire list must be written out, or a specific existing slot must be modified directly. There is no shorthand that merges partial data automatically. For adding a single build option to an existing unit, the pattern is unit.buildoptions[#unit.buildoptions + 1] = "whatever", assuming unit is a valid unit definition.
If adding multiple build options, each new entry needs its own append call. The system does not accept a partial array merge.
A common question is whether buildoptions additions are additive or require the full array. The answer depends on the modding approach. When using tweakunits directly, the full list must be provided. When appending individually with buildoptions[#buildoptions + 1], entries stack on top of the existing set.
The additive approach is safer for small changes. Overwriting the entire table risks dropping build options added by other tweaks or the base game.
When exporting unit definitions as JSON, the output includes many columns that map to Spring RTS game engine internals. Reference documentation at the Spring RTS wiki covers UnitDefs and WeaponDefs in detail. Many columns exist in both LUA and non-LUA variants, which creates duplicates in export spreadsheets.
Working through these exports takes patience. The key is to identify which fields actually matter for the unit being modified and ignore the rest.
Explosion behavior sits outside the tweakunits and tweakdefs system entirely. The explosion radius and visual effect are defined in the weapon definitions, specifically in the unit explosions Lua file within the BAR repository.
Creating a custom explosion requires two steps. First, add an entry to the weapon explosions Lua file. Second, reference that new explosion from the appropriate weapon or unit death handler. Changing explosion radius through tweakdefs alone will not work because explosions are not part of that layer.
Units like the Commander, JUG, or AFG each use distinct explosion presets. Replicating those effects means finding the matching entry in the explosions Lua file and copying or modifying it.
buildoptions, customparams, weapondefs, and weapons subtables in tweakdefsbuildoptions[#buildoptions + 1] instead of replacing the full arrayModding BAR takes patience and a willingness to learn from mistakes. Those same qualities make for great teammates. Creed of Champions values players who put in the work, share knowledge, and keep things constructive. Check out the channel for community-focused gameplay content.
[Crd] The removal of toxicity, the goal of fun and learning, makes for a refreshing spot to play and spend time. It has also made a game with plenty of complexity a bit less daunting to dive into.