BAR Modoptions Explained and URL-Safe Base64 Encoding for Tweaks

Modoptions control game behavior at the lobby level. Understanding where the logic lives and how to encode tweak strings with URL-safe Base64 prevents common roadblocks.

Tags: Beyond All Reason modding, modoptions, URL-safe Base64 encoding, tweak strings, alldefs_post, game logic

Where the modoptions logic lives

BAR stores modoptions logic in gamedata/alldefs_post.lua. The definitions around line 202 show how the game reads lobby settings and applies them to unit definitions. This is the backend, not the UI. The lobby presents options as toggles and sliders, but the actual behavior comes from that file.

Any modder wanting to add, remove, or change a lobby option needs to work with alldefs_post. The file contains the mapping between what players see in the lobby and what the engine actually does with each setting.

Compiling tweaks with URL-safe Base64

Tweak strings in BAR must use URL-safe Base64 encoding. Standard Base64 is not sufficient. The difference matters because URL-safe Base64 replaces + and / with - and _, and strips the trailing = padding in most BAR workflows.

The process for encoding a custom tweak is straightforward:

Online tools offer URL-safe Base64 encoding. Any encoder that only outputs standard Base64 will produce strings that fail in BAR.

Common tweakunits lobby errors

The tweakunits blocked error ("not allowed with current mod or battle preset") appears when the lobby mode restricts modifications. Tournament mode blocks tweakunits by design. Setting the lobby to Custom or Coop resolves the issue. The game requires an unrestricted preset to accept any tweak strings, regardless of how correctly they are encoded.

If encoding is correct and the preset is permissive but errors persist, check that the tweak string has not grown too large for the lobby field. Extremely complex unit modifications can exceed the character limit.

Debugging encoded tweaks

When a tweak string fails silently, the decoding step is usually the problem. A good debugging approach is to paste the tweak string into a Base64 decoder and verify it produces valid Lua. If the decoded string contains syntax errors, indentation problems, or incomplete tables, those will appear cleanly in plain text form.

The BAR source on GitHub is the definitive reference. Reading through alldefs_post.lua and tweakdefs files shows exactly what structure the encoded tweaks must produce after decoding.

Wrapping up

URL-safe Base64, Custom lobby mode, and reading alldefs_post.lua cover the majority of modoptions questions. Get those three right and the rest falls into place. For players looking for visual guides on BAR gameplay and strategy, the community YouTube channel at Beyond All Reason YouTube covers a wide range of topics.

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.