| 08-03-2009, 07:12 PM | #1 |
Because of this bug it isn't so easy. JASS:library IsUnitIdValid uses IsGameLoaded globals private unit U endglobals function IsUnitIdValid takes integer i returns boolean if IsGameLoaded() then // ofc i plan to store the result, to avoid the creation of the unit all the time, when it was already checked // but i'm waiting for hashtables available on the official patch set U = CreateUnit(Player(0),i,0.,0.,0.) // yeah i should use a dummy player and constants reals X/Y instead if GetWidgetLife(U) != 0 then call RemoveUnit(U) return true else return false endif else return UnitId2String(i) != null endif endfunction endlibrary Better ideas ? PS : I don't want to store a boolean manually for each unitid possible on the map EDIT : In case you wonder what is the function IsGameLoaded : JASS:library IsGameLoaded initializer init globals private boolean B = false endglobals function IsGameLoaded takes nothing returns boolean return B endfunction private function Actions takes nothing returns nothing set B = true endfunction private function init takes nothing returns nothing local trigger trig = CreateTrigger() call TriggerRegisterGameEvent(trig,EVENT_GAME_LOADED) call TriggerAddAction(trig,function Actions) endfunction endlibrary EDIT 2 : It seems that IssueBuildOrderById() always returns true while the arguments are "valids" (existent unit and order). I mean it returns true for any existent order, "move" for example ... |
| 08-04-2009, 03:30 PM | #2 |
Uses...? |
| 08-04-2009, 03:33 PM | #3 |
what about return GetObjectName(i) != "" |
| 08-04-2009, 03:59 PM | #4 | ||
Quote:
Quote:
Or at least it will return true if you make an error on the script, since unitid, itemid and so one ... doesn't exist really, they are just integer, an error is easy to make. I would still prefer the unit creation. |
| 08-04-2009, 04:56 PM | #5 |
It seems that simply check if unit isn't null after the CreateUnit... works. I don't think someone will find a better way, but if you have one, let me know it. |
