• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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