The Spring RTS wiki is incomplete, the engine source is better, and Lua for-loop syntax catches new modders off guard.
Tags: bar modding, unitdefs reference, springrts wiki, lua for loops, unitdef cpp, spring echo
The Spring RTS wiki at springrts.com has a UnitDefs page listing traits like activatewhenbuilt, metalcost, and health. It was useful years ago but BAR has diverged from the Spring engine enough that the wiki is incomplete and growing more obsolete. Many BAR-specific unit definitions and weapon parameters are not documented there at all.
The definitive source for what unit definition fields exist and what values they accept lives in the BAR Spring engine source on GitHub. The file rts/Sim/Units/UnitDef.cpp in the BAR105 branch shows every field the engine reads for unit definitions. Start around line 275 for the core unitdef parsing logic. This is where you see exactly which fields are recognized, what types they expect, and how they interact.
If you want to check whether a specific trait name is valid, the engine source is the answer. The wiki guesswork will waste your time.
A common stumbling block is the numeric for-loop in Lua. The syntax is for variable = start, end do. You cannot pre-declare the loop variable and then try to use it as the loop iterator. Pre-declaring triggers a syntax error.
You also do not need to start at 1. A loop like for x = 5, 10 do is perfectly valid. Just make sure the loop variable appears for the first time in the for statement itself.
For debugging, Spring.Echo() prints values to the game log. Wrap variables in Spring.Echo(variableName) to verify your loops are iterating correctly.
Digging into BAR source code and modding resources sharpens your game sense beyond what any guide can teach. Creed of Champions is a community that values exactly this kind of curiosity. Serious RTS play without the toxic baggage. Players share knowledge, run training sessions, and compete at a high level in a genuinely supportive environment. If you want people who understand why you care about game mechanics down to the engine level, this is the place.
[Crd] Gaming actually fulfills a human purpose here - cooperation, mutual upbuilding, fun and striving for greatness together. Instead of random anonymity, you meet, learn from, and enjoy real people.