How to use IssueUnitCommand?

Everything about mods can be found here.

Moderator: Morax

How to use IssueUnitCommand?

Postby iliis » 16 Sep 2018, 07:48

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 :(
iliis
Crusader
 
Posts: 15
Joined: 18 Jan 2012, 12:44
Has liked: 0 time
Been liked: 0 time

Re: How to use IssueUnitCommand?

Postby speed2 » 16 Sep 2018, 08:17

This wont work and if you think about it it's restricted for a very good reason, you won't make a UI mod that will move units for you.
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: How to use IssueUnitCommand?

Postby iliis » 16 Sep 2018, 08:26

Do you mean it has been patched out? Because giving commands to units is certainly possible in a UI mod (for example upgrading things).
iliis
Crusader
 
Posts: 15
Joined: 18 Jan 2012, 12:44
Has liked: 0 time
Been liked: 0 time

Re: How to use IssueUnitCommand?

Postby speed2 » 16 Sep 2018, 08:32

It was never available, Im not saying all commands but move, attack, reclaim, patrol is surely not possible.
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: How to use IssueUnitCommand?

Postby iliis » 16 Sep 2018, 08:36

Darn. Are you sure? Is this documented?
iliis
Crusader
 
Posts: 15
Joined: 18 Jan 2012, 12:44
Has liked: 0 time
Been liked: 0 time

Re: How to use IssueUnitCommand?

Postby speed2 » 16 Sep 2018, 08:51

I'm sure and it's not documented.
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: How to use IssueUnitCommand?

Postby iliis » 16 Sep 2018, 08:55

Well, at least we have this thread now :S Might save somebody else a day of frustration...
iliis
Crusader
 
Posts: 15
Joined: 18 Jan 2012, 12:44
Has liked: 0 time
Been liked: 0 time

Re: How to use IssueUnitCommand?

Postby iliis » 16 Sep 2018, 08:56

The strange thing is, the move command actually makes it into the unit's command queue, but the target position is NaN...
iliis
Crusader
 
Posts: 15
Joined: 18 Jan 2012, 12:44
Has liked: 0 time
Been liked: 0 time

Re: How to use IssueUnitCommand?

Postby Exotic_Retard » 16 Sep 2018, 10:53

hi, would you be willing to give us a little bit more info on what sort of mod you are making? we might be able to help you with any other issues you might have, even if this one isnt working out :>
User avatar
Exotic_Retard
Contributor
 
Posts: 1470
Joined: 21 Mar 2013, 22:51
Has liked: 557 times
Been liked: 626 times
FAF User Name: Exotic_Retard

Re: How to use IssueUnitCommand?

Postby iliis » 16 Sep 2018, 11:02

Heh, that's very kind of you, thanks! :)
I'm working on a mod that better visualizes reclaim, somewhat in the spirit of viewtopic.php?f=41&t=16635 (even though I wasn't aware of that mod when I started mine). See https://github.com/iliis/EcoViz for more, including a few screenshots.
I wanted to add a feature where one could issue a reclaim command to a group of wrecks and it would automatically set a reclaim command to every item in the group, basically like the Area Command mod did (https://www.youtube.com/watch?v=MGjYqpT ... .be&t=1m6s).
So far I've managed on my own, with the sparse information that's out there on the web and the existing Lua code, but of course help is always appreciated :)
iliis
Crusader
 
Posts: 15
Joined: 18 Jan 2012, 12:44
Has liked: 0 time
Been liked: 0 time

Next

Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest