Append units to a factory's build menu without overwriting existing slots by using the next available index number.
Tags: bar modding, buildoptions, tweakunits, firing modes, lua bit operations
Each factory in BAR has a numbered buildoptions table. The default factories use indices 1 through 33. To add a new build option, use the next available number, like 34. The syntax looks like this: {armca = {buildoptions = {[34] = "armlichet4"}}}. If you reuse an existing index, you overwrite that factory's current build slot instead of appending.
Count the existing buildoptions on your target factory first, then set your new entry to the next integer after the highest existing index.
Adding firing modes to units that do not natively support them through tweakunits does not work. The weapon toggle system, exemplified by the unit_hound_weapon_toggle gadget, requires specific engine support built into the unit definition. Tweakunits can modify existing weapon parameters but cannot add toggle behavior where none exists.
The BAR engine uses 32-bit floating point numbers with a 24-bit mantissa for Lua bit operations. This means bitwise operations are safe only up to 24-bit integers. Values beyond that range lose precision and produce incorrect results. Keep any bitwise logic in your gadgets and widgets within the 24-bit ceiling.
Knowing these engine quirks saves hours of debugging time. Players who share their findings help everyone skip the same mistakes. Creed of Champions builds on that knowledge-sharing mentality by running games and discussions where experience gets passed on to newer members without gatekeeping.
Before discovering Creed, I was thinking the only thing that separates BAR from the perfect RTS is a friendly and safe social environment for new players to learn and feel included.