Using set target command in BAR widgets and choosing a lua editor
How to replace attack orders with set target in widget code, finding command constants, and picking the right text editor for BAR modding.
Replacing attack with set target in widget code
If a widget uses CMD.ATTACK with spGiveOrderToUnit() but you need the unit to set a target instead of attacking immediately, swap in CMD_UNIT_SET_TARGET with the command ID 34923.
The full pattern looks like this:
local CMD_UNIT_SET_TARGET = 34923
spGiveOrderToUnit(unitID, CMD_UNIT_SET_TARGET, {nearestEnemy}, {})
The command constant lives in the BAR source file at luaui/Widgets/cmd_default_set_target.lua. This reference is useful whenever you need custom target-setting behavior in widgets that would otherwise trigger immediate attacks.
Choosing a text editor for widget development
You can edit BAR widget files in any text editor. Notepad works. But an editor that understands Lua syntax saves time through syntax highlighting, bracket matching, and error detection.
Recommended options:
- Visual Studio Code with the Lua extension provides full language support
- Notepad++ with Lua syntax highlighting handles basic needs
- Sublime Text offers lightweight editing with Lua packages
VS Code is the community preference for its integrated terminal, file search, and Lua debugging extensions.
Share knowledge, build better teams
The right tools make learning faster. Creed of Champions members share setup advice from editors to widgets to control schemes. No one gets mocked for starting with Notepad.
[Crd] The first and only community I have seen that actually holds up to its values. I have honestly not had a single bad experience here.
Win with skill, teamwork, and respect.