Fixing bset encoded tweaks and avoiding BAR tweakdefs crashes
How to format encoded tweak values, which unitdef keys work, and why your mod keeps crashing during gamedata loading.
The bset encoded value format
BAR lobby tweak commands use !bset followed by a tweak slot and a Base64-encoded value. A common mistake is including the !bset tweakunits text inside the encoded line itself. Do not encode those words. Encode only the value data.
The correct format encodes just the table structure. For example, encoding a unit energy cost change means the Base64 string contains nothing but the Lua table with the new value.
Tweakdefs format rules
Getting tweakdefs to not crash requires following strict formatting rules:
- One subtable per unit, not all units flattened into one table
- Keys must be lowercase
- Every subtable needs proper comma separation between entries
Correct format example:
{ armamph = { energycost = 4250, buildcostmetal = 380, health = 1700 }, armaak = { health = 1650 } }
Not all unitdef parameters work through tweaks. The buildcostenergy line works. The energycost parameter does not. Unit names cannot be changed through tweakdefs at all. Model size uses the xsize and zsize parameters from the unitdef table.
Crash debugging during gamedata loading
If the game crashes during the Gamedata loading phase with tweakdefs active, the most likely causes are malformed Lua syntax or invalid table structure. A missing closing brace causes the parser to hit end-of-file unexpectedly, generating a generic load failure.
The debugging approach: start with a single unit change in your tweak table. Verify it loads without crash. Then add additional units one at a time until the crash appears. The last addition pinpoints the problematic entry.
Learning together without blame
Tweakdefs debugging frustrates everyone at first. The community that helps you through it matters. Creed of Champions values patience when people are learning, whether that learning is BAR strategy or mod code.
[Crd] I love being able to communicate with my team, getting and sharing tips and constructive feedback on gameplay.
Better teammates. Better games. Competitive play without the toxicity.