Beyond All Reason tweakdefs modding guide

A practical rundown of tweakdefs basics, common pitfalls, unit explosions, and adding weapons via Lua in BAR.

Tags: bar modding, tweakdefs, tweakunits, lua modding, unitdefs, weapondefs, unit explosions

What tweakdefs actually do

Tweakdefs is the go-to system for tweaking unit definitions, weapon stats, and other game data on the fly without rebuilding the entire mod. It works through lobby commands and Lua hooks, letting you test changes before committing them to a full mod.

The core workflow is simple: define the changes you want, apply them through the tweak system, then test in-game. The trick is that it demands clean syntax. A missing subtable, a nil value that was never checked, or a typo in a unit name will quietly break the whole load.

Common tweakdefs mistakes and how to fix them

Most tweakdefs issues come down to a handful of patterns. Malformed Lua tables are the biggest culprit. If you open a subtable and forget to close it, the parser fails silently and the tweak just never applies.

Missing subtables cause another wave of errors. When you reference unitDef.weapondefs on a unit that has no weapons defined yet, you get nil. The fix is defensive coding: check if the subtable exists before writing into it. Using unitDef.weapondefs = unitDef.weapondefs or {} before adding entries prevents that crash.

Lobby command setup errors show up as tweaks that simply do not fire. Double-check that your command is actually being registered and that it targets the right unit or weapon definition slot.

The definitive reference guide lives on GitHub as the Tweakdefs and Tweakunits gist by badosu. That document is the starting point for anyone serious about modding BAR.

Editing unit explosions

You can change how a unit explodes by modifying the explodeas parameter on the unit definition. What you cannot do is define a brand-new explosion type from scratch. You are limited to the existing explosion definitions in the game files.

The explosion definitions live in weapons/Unit_Explosions.lua in the BAR repository on GitHub. Browse that file to see what explosion types are available, then set your units explodeas field to one of those existing types. That is as far as you can go without deeper engine work.

Adding weapons or shields to units via Lua

A common modding question is whether you can add a new weapon or shield to existing units. The short answer is yes, with caveats.

For weapons, you can iterate over UnitDefs in Lua, check or create the weapondefs table, and push a new weapon definition onto it. A typical pattern looks like looping over units with pairs(UnitDefs), using string.sub to filter by faction prefix like "arm" or "core", then appending your new weapon definition to the weapondefs array.

Shields are trickier. Adding a repulsor or shield generator to a unit that lacks the animation support for it will produce odd visual behavior. The shield might work functionally but look broken because the unit has no shield animation baked in. You can still try it and the game will not crash, but the visual result may disappoint you.

Best practices for BAR modding

Always test tweakdefs changes in a custom lobby game before assuming they work. The game loads definitions differently in singleplayer skirmish versus multiplayer, and a tweak that works locally might misbehave when synced across clients.

Keep your definitions defensive. Nil checks, table existence guards, and careful indexing are the difference between a tweak that works and one that silently does nothing.

When in doubt, read the source. The BAR codebase on GitHub is open and well-organized. The Unit_Explosions.lua file mentioned above is just one example. Digging into unitdefs.lua and weapondefs.lua directly will teach you more than any tutorial.

Creed of Champions

Modding BAR deepens your understanding of how units work, which translates directly into better gameplay. Knowing why a unit behaves a certain way under the hood sharpens your strategic instincts. Creed of Champions is the kind of community where that curiosity is rewarded. Competitive play. Zero team-blame. Players who dig into the mechanics and share what they find make everyone around them better. Training sessions, team gameplay, and a genuinely low-drama environment. If you want a place to learn, experiment, and improve without the hostility, check them out.

[Crd] Creed of Champions rekindled my joy in Beyond All Reason. I had burned out on the game, and the friendly, no-toxicity environment caused me to start enjoying it again.