I'm working on a UI mod and I'd like to give my units some commands like Move or Reclaim. There is a function called
IssueUnitCommand() that should do this. However I have been absolutely unable to figure out how to get it to work.
The signature according to the docs is:
- Code: Select all
IssueUnitCommand(unitList,command,[string],[clear])
It does work for simple commands that don't need additional parameters, e.g.:
- Code: Select all
IssueUnitCommand(GetSelectedUnits(), "UNITCOMMAND_Stop")
The only example I could find that uses additional parameters are "Script" commands:
- Code: Select all
local orderData = {
TaskName = "EnhanceTask",
Enhancement = "ResourceAllocation",
}
IssueUnitCommand({unit}, "UNITCOMMAND_Script", orderData, false)
This also works as expected, starting the RAS upgrade on the commander. But what parameters do "UNITCOMMAND_Move" or "UNITCOMMAND_Reclaim" expect? I tried everything I could think of, like
- Code: Select all
IssueUnitCommand(selected_units, "Move", {10,20,30}, true)
or
- Code: Select all
local pos = {
Type = 'Position',
Position = Vector(10.1,20.2,30.3),
}
IssueUnitCommand(selected_units, "Move", pos, true)
I tried passing it as a string. I hooked
OnCommandIssued to see what manually issued commands produce. Etc. Without success tough