-
Notifications
You must be signed in to change notification settings - Fork 21
BlzGroupUnitAt: remove comment about removed units being returned as … #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@Luashine please confirm |
edit: Did a mistake in Lua. In Lua, I have the delay as well. Maybe it is specific unit properties then that make it not immediately be removed. Conducting further tests... edit2: Or looking at your timestamps, do you have a delay as well between the instructions? |
1.32.10 maps Unit Removal Test.zip Good test. I extended it to avoid manual mistakes for Jass and transpiled to Lua (and fixed string concat). Jass and Lua behave the same. The unit is not immediately considered removed from the game, but after sleep the handle really returns null. Untested cases:
This means that FirstOfGroup iterators work fine in almost all cases except Removal+Sleep which should be really odd cases. That note must be updated.
---@param b boolean
---@return string
function B2S(b)
if b then
return "true"
end
return "false"
end
getmetatable("").__add = function(obj, obj2) return obj .. obj2 end
--native UnitAlive takes unit id returns boolean
-- Jass result, 1.32.10:
-- Unit original handle: false,Footman,alive=true;deadBJ=false
-- Unit groupAt handle: true;;alive=false;deadBJ=true
-- Lua result, 1.32.10:
-- same as Jass above
function TestUnitRemoval()
local u_getgroup ---@type unit
local msg1 ---@type string
local msg2 ---@type string
local g = CreateGroup() ---@type group
local u_created = CreateUnit(Player(0), FourCC('hfoo'), -30, 30, 42) ---@type unit
GroupAddUnit( g, u_created )
RemoveUnit(u_created)
msg1 = "Unit original handle: " + B2S(u_created == nil) + ";" + GetUnitName(u_created)
msg1 = msg1 + ";alive=" + B2S(UnitAlive(u_created)) + ";deadBJ=" + B2S(IsUnitDeadBJ(u_created))
msg1 = msg1 + ";pos=" + R2S(GetUnitX(u_created)) + ";" + R2S(GetUnitY(u_created))
TriggerSleepAction(0)
u_getgroup = BlzGroupUnitAt(g, 0)
msg2 = "Unit groupAt handle: " + B2S(u_getgroup == nil) + ";" + GetUnitName(u_getgroup)
msg2 = msg2 + ";alive=" + B2S(UnitAlive(u_getgroup)) + ";deadBJ=" + B2S(IsUnitDeadBJ(u_getgroup))
msg2 = msg2 + ";pos=" + R2S(GetUnitX(u_getgroup)) + ";" + R2S(GetUnitY(u_getgroup))
-- Messages are intentionally not displayed immediately out of fear of delaying anything
BJDebugMsg(msg1)
BJDebugMsg(msg2)
DestroyGroup(g)
g = nil
u_created = nil
u_getgroup = nil
end
--Conversion by vJass2Lua v0.A.2.3 |
…null