• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] [Lua] Getting Last Created Unit help

Status
Not open for further replies.
Level 8
Joined
Jun 16, 2008
Messages
333
Lua:
function createUnitfunc()
    CreateUnitAtLoc(Player(15), FourCC("h001"), GetRectCenter(udg_createUnitReg[1]), 0)
    local lcu = GetLastCreatedUnit()
    IssuePointOrderLoc(lcu, "move", GetRectCenter(udg_createUnitReg[2]))
end

I am trying to move the unit after it is created. It is created, just doesn't move.
 
GetLastCreatedUnit() does return a global unit variable (bj_lastCreatedUnit) which is only set by Unit Create functions from Blizzard.j.
You use a native from common.j, CreateUnitAtLoc. CreateUnitAtLoc returns the unit created. it is recommented to set your local with the returned Unit
local lcu = CreateUnitAtLoc .....
 
Level 8
Joined
Jun 16, 2008
Messages
333
I was thinking that might be possible but never tried it. Thank you for your help!
GetLastCreatedUnit() does return a global unit variable (bj_lastCreatedUnit) which is only set by Unit Create functions from Blizzard.j.
You use a native from common.j, CreateUnitAtLoc. CreateUnitAtLoc returns the unit created. it is recommented to set your local with the returned Unit
local lcu = CreateUnitAtLoc .....
 
Status
Not open for further replies.
Top