Setting up VSCode for BAR Lua modding and widget scripts

Writing Beyond All Reason mods in VSCode without Spring API autocomplete throws red squigglies everywhere. UnitDefs, widget callbacks, and Spring engine calls show as undefined. Here is a fast way to get intellisense working and start iterating on scripts without fighting the editor.

Tags: BAR modding, VSCode Lua setup, Spring intellisense, widget scripts, unit banning, beyond all reason

VSCode Lua intellisense for Spring engine

The BAR wiki has a work-in-progress page on configuring VSCode for Lua intellisense that provides stub definitions for Spring engine APIs. Setting those up turns Spring.GiveOrderToUnit, widget:GameFrame, and other engine calls from red errors into autocomplete suggestions. Grab the Spring API stubs from the wiki page and drop them into a local workspace subdirectory that VSCode indexes. Lua language server picks them up automatically after a restart.

Where to find widget code for reference

The BAR repository on GitHub contains every widget in the luaui/Widgets/ directory. Reading an existing widget that does something close to what you want saves hours. gui_top_bar.lua is clean and small. Widgets with unit restriction or team coloring are useful references too. The pattern to find is: define the widget table, implement the required callbacks like Initialize and GameFrame, and call Spring API functions with correct argument types.

Banning and restricting units with unitrestricted

To unrestrict banned units through code, set the unitrestricted flag to 0 on target unit definitions. Create a ban list table keyed by internal unit name, iterate through UnitDefs with pairs, and flip the flag for matching entries. Internal unit names match the short identifier in the URL on beyondallreason.info. For example, corak is the grunt unit name. The pattern uses banList["corwin"] = true style entries for clean lookup.

Finding unit internal names

Every unit has a short internal name used in Lua code and configuration files. The easiest way to find it is the URL on beyondallreason.info. The page for any unit uses the internal name as the path segment. https://www.beyondallreason.info/unit/corak points to corak, which is also the name you use in UnitDefs lookups. This avoids digging through unit definition files manually every time.

Troubleshooting missing panels or content

If a widget panel appears empty when it should show unit lists or team data, check the widget initialization order first. Spring loads widgets before all unit definitions are available in some cases. Verify the widget is actually reading from the correct table and that the game state is populated. A simple print statement in the widget output confirms data flow.

Creed of Champions

Creed of Champions keeps the learning curve manageable with players who answer questions instead of dismissing them. Modding BAR is easier when someone actually explains the pattern versus watching you struggle alone. People here run custom games and test each other's widgets regularly. That kind of cooperative environment is rare in competitive RTS spaces.

[Crd] Creed of Champions is a great place to learn and play BAR in a friendly atmosphere. Training sessions, team gameplay, even some non-BAR stuff. Large cross section of abilities, time zones, and game mode interests.