From the current wiki, this is what we're mainly dealing with AFAIK:
Code: Select all
Spring.GiveOrderToUnit
( number unitID,
number cmdID,
params = {number, etc...},
options = {"alt", "ctrl", "shift", "right"} ) -> nil
The first parameter is straight forward, simply wich unit will receive the order. The second parameter, cmdID is a bit trickier. I think this refers to wich command is to be given. I found this list in the spring source code wich I think is what goes in here:
I think you have to write actually a period instead of the underscores, I have seen people redefine the command names to use an underscore. Then there's a pair of special command ids, namely:00012 #define CMD_STOP 0
00013 #define CMD_INSERT 1
00014 #define CMD_REMOVE 2
00015 #define CMD_WAIT 5
00016 #define CMD_TIMEWAIT 6
00017 #define CMD_DEATHWAIT 7
00018 #define CMD_SQUADWAIT 8
00019 #define CMD_GATHERWAIT 9
00020 #define CMD_MOVE 10
00021 #define CMD_PATROL 15
00022 #define CMD_FIGHT 16
00023 #define CMD_ATTACK 20
00024 #define CMD_AREA_ATTACK 21
00025 #define CMD_GUARD 25
00026 #define CMD_AISELECT 30
00027 #define CMD_GROUPSELECT 35
00028 #define CMD_GROUPADD 36
00029 #define CMD_GROUPCLEAR 37
00030 #define CMD_REPAIR 40
00031 #define CMD_FIRE_STATE 45
00032 #define CMD_MOVE_STATE 50
00033 #define CMD_SETBASE 55
00034 #define CMD_INTERNAL 60
00035 #define CMD_SELFD 65
00036 #define CMD_SET_WANTED_MAX_SPEED 70
00037 #define CMD_LOAD_UNITS 75
00038 #define CMD_LOAD_ONTO 76
00039 #define CMD_UNLOAD_UNITS 80
00040 #define CMD_UNLOAD_UNIT 81
00041 #define CMD_ONOFF 85
00042 #define CMD_RECLAIM 90
00043 #define CMD_CLOAK 95
00044 #define CMD_STOCKPILE 100
00045 #define CMD_DGUN 105
00046 #define CMD_RESTORE 110
00047 #define CMD_REPEAT 115
00048 #define CMD_TRAJECTORY 120
00049 #define CMD_RESURRECT 125
00050 #define CMD_CAPTURE 130
00051 #define CMD_AUTOREPAIRLEVEL 135
00052 #define CMD_LOOPBACKATTACK 140
00053 #define CMD_IDLEMODE 145
CMD_INSERT
CMD_REMOVE
These are used to put a command into the command queue (=waypoint list) at a specified location.
Now for the really tricky part, the params and options parameters. Params is a table (kind of struct/array) containing the parameters for the order itself, such as coordinates for a move order or a unit to guard for a guard order, etc. Im really not sure what options does at the moment.
For a simple example let's consider the CMD_MOVE, from the recent popular customformations widget:
Code: Select all
Spring.GiveOrderToUnit(unitID, cmdTag, pos, keyState)
Code: Select all
local cmdTag = CMD.MOVE
Next, we have the CMD_INSERT and CMD_REMOVE. The example in this case is the saboteur script:
Code: Select all
GiveOrderToUnit(unitID,CMD_INSERT,{-1,CMD_CAPTURE,CMD_OPT_INTERNAL+1,unitID2},{"alt"});
GiveOrderToUnit(unitID,CMD_INSERT,{cmd.tag,CMD_CAPTURE,CMD_OPT_INTERNAL+1,unitID2},{});
GiveOrderToUnit(unitID,CMD_INSERT,{0,CMD_STOP,0},{"alt"});
Future topics:
List of all parameters for all commands.
How to make and use Custom commands.
Variants, such as Spring.GiveOrderArrayToUnitMap (heh, no clue what that means).