Hi,
Im probably being really thick here, but Im trying to grab the currently 'selected' unit (whenever a unit selection changes, i grab the newly selected unit) so that I can check its type and the feature (if any) its standing on.
I found the UnitSelectionChanged event, so I tied a listener function to it and determined that my listener is being passed 5 parameters (Ive guessed what they do when I can):
The event seems to fire, and I get differing values when I select units, I.e:
Output: [0] [24578] [7] [14] [0] [true] [false]
Output: [0] [8192] [6] [14] [0] [true] [false]
Output: [0] [8192] [6] [14] [0] [true] [false]
So, I figured the 2nd parameter (some_object) is a Unit object, but trying to use a getUnitType() on it gives me a 'attempt to index local 'some_object' (a number value) runtime error.
So, perhaps it is just an ID of the unit. But how do I get 'at' the unit so that I can retrieve its details (check its type etc)?
Also, does anyone know if the event 'UnitSelectionChanged' would also fire when the AI changes their unit selection, not just the player?
Thanks
Dave
Im probably being really thick here, but Im trying to grab the currently 'selected' unit (whenever a unit selection changes, i grab the newly selected unit) so that I can check its type and the feature (if any) its standing on.
I found the UnitSelectionChanged event, so I tied a listener function to it and determined that my listener is being passed 5 parameters (Ive guessed what they do when I can):
Code:
function doSomething(unknownvar1, some_object, x, y, unknownvar3, unknownvar4, unknownvar5)
print("Output: ["..tostring(unknownvar1).."] ["..tostring(some_object).."] ["..tostring(x).."] ["..tostring(y).."] ["..tostring(unknownvar3).."] ["..tostring(unknownvar4).."] ["..tostring(unknownvar5).."]");
end
Events.UnitSelectionChanged.Add(doSomething);
The event seems to fire, and I get differing values when I select units, I.e:
Output: [0] [24578] [7] [14] [0] [true] [false]
Output: [0] [8192] [6] [14] [0] [true] [false]
Output: [0] [8192] [6] [14] [0] [true] [false]
So, I figured the 2nd parameter (some_object) is a Unit object, but trying to use a getUnitType() on it gives me a 'attempt to index local 'some_object' (a number value) runtime error.
So, perhaps it is just an ID of the unit. But how do I get 'at' the unit so that I can retrieve its details (check its type etc)?
Also, does anyone know if the event 'UnitSelectionChanged' would also fire when the AI changes their unit selection, not just the player?
Thanks
Dave