I have this portion of a code that logs when a command is being execute.
Code:
function widget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdOpts, cmdParams) local txt local x,y,z = Spring.GetUnitPosition(unitID) if cmdID == 36525 then -- Special On/Off Command txt = "Unit ID "..unitID.." of Team "..unitTeam.." was commanded to the special weapon" write(txt) end end
The logger works for other command, for e.g. attack, turn, wait, guard. However, it does not log for this special command which I create. Anyone have any suggestion what may went wrong?
function widget:CommandNotify(id, params, options)
This collects custom widget commands. It may be the only function that does so because custom widgets commands are local (I would not be surprised if UnitCommand was only for synced commands).
function widget:UnitCommand(unitID, unitDefID, unitTeam, cmdID, cmdOpts, cmdParams) Spring.Echo ("bla") end
This echo is display when my custom commands are run.
However, it is command ID 70 instead of my custom command ID.
These are the custom command I have that echo the correct command ID: CMD_RADAR - command ID 35525 CMD_TURN - command ID 35521 CMD_MORPH - commandID 3210
These 2 does not, it only activates the command ID 70 instead of its respective command shown below. CMD_SPECIAL - commandID 36525 CMD_SMOKE - commandID 35520
I did both code (CMD_RADAR and CMD_SPECIAL) in the similar manner. Any suggestions why the difference in the command ID being pick up?
2. function widget:CommandNotify(cmdID, params, options) Able to detect my special commands being activated. However, is there a way to get the unitID and TeamID from the cmdID?
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum