Basically, UnitBeginCmd would be fired when a unit starts executing a command.
Attempting to do it using UnitCommand/UnitCmdDone is very difficult (I tried, up to 50 lines atm), mainly due to insert/remove commands and wait toggling. And then there's all the special cases, like inserted waits.. Also the lua (if done) would need to appear in every widget/gadget that needed this functionality, making them very messy / hard to update (I would probably use it in half a dozen at least)
New lua callin UnitBeginCmd
Moderator: Moderators
Re: New lua callin UnitBeginCmd
An example;
If I give a unit 5 queued move commands, at the point in time where it actually starts /executing/ each of those commands, it will fire UnitBeginCmd, so you'd get 5 calls spaced over some period of time, one for each move.
If I give a unit 5 queued move commands, at the point in time where it actually starts /executing/ each of those commands, it will fire UnitBeginCmd, so you'd get 5 calls spaced over some period of time, one for each move.
Re: New lua callin UnitBeginCmd
you can fake it in current spring using UnitCommand and UnitCmdDone, checking the queue on each one (when a command finishes, a unit is working on the next command?)
Re: New lua callin UnitBeginCmd
Why not keep track of commands issued, instead? Then you know when Wait has ceased, and can evaluate the list at that time.
Re: New lua callin UnitBeginCmd
I wouldn't have posted this if those very simple methods suggested worked.
Another example...
I have a unit with a move command, I insert a fight command at the front of queue. This is what happens:
UnitCommand: cmd=Insert (param=FIGHT). Queue: Move, max_speed
UnitCmdDone: cmd=Move. Queue: Move, max_speed
UnitCommand: cmd=max_speed. Queue: Fight, move, max_speed
Problems:
a) Need to extract fight command from the insert
- Including insert position, + is it now at front of queue
b) UnitCmdDone is bugged. It says that the move command is complete (which it is, as it now isn't the current command), yet GetUnitCommands will return the queue with the move still in it, and missing the inserted command.
c) There are max_speed commands scattered all over the place, which could cause more special case problems.
As I mentioned in first post, I tried writing code that used UnitCommand/UnitCmdDone and I got up to 50 lines in order to handle all these cases. It /apparently/ works, but it is too large and I don't trust it enough to go ahead and copy-paste it into half a dozen other widgets. It would be much nicer if there was a simple UnitBeginCmd callin which gets called in the source when a unit starts working on a command.
Another example...
I have a unit with a move command, I insert a fight command at the front of queue. This is what happens:
UnitCommand: cmd=Insert (param=FIGHT). Queue: Move, max_speed
UnitCmdDone: cmd=Move. Queue: Move, max_speed
UnitCommand: cmd=max_speed. Queue: Fight, move, max_speed
Problems:
a) Need to extract fight command from the insert
- Including insert position, + is it now at front of queue
b) UnitCmdDone is bugged. It says that the move command is complete (which it is, as it now isn't the current command), yet GetUnitCommands will return the queue with the move still in it, and missing the inserted command.
c) There are max_speed commands scattered all over the place, which could cause more special case problems.
As I mentioned in first post, I tried writing code that used UnitCommand/UnitCmdDone and I got up to 50 lines in order to handle all these cases. It /apparently/ works, but it is too large and I don't trust it enough to go ahead and copy-paste it into half a dozen other widgets. It would be much nicer if there was a simple UnitBeginCmd callin which gets called in the source when a unit starts working on a command.
Re: New lua callin UnitBeginCmd
The easiest way I know would be to use a custom command and handle it in CommandFallback.