• 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.

unit u inst stored in function b right?

Status
Not open for further replies.
Level 24
Joined
Aug 1, 2013
Messages
4,658
There are 2 different unit u.
In function a, there is unit u, which points to GetTriggerUnit().
That pointer is sent to function b.
In function b, there is another unit u, which points to the same GetTriggerUnit().

So if you mean, are they both the same unit? then yes.
If you mean, are they the same variable? then no.
If you do this, you still displays the name twice:
JASS:
function b takes unit u returns nothing
    call BJDebugMsg("unit name = " + GetUnitName(u))
    set u = null
endfunction

function a takes nothing returns nothing
    local unit u = GetTriggerUnit()
    
    call b(u)
    
    call BJDebugMsg("unit name = " + GetUnitName(u))
    
    set u = null
endfunction

EDIT:
On the other hand...
this is function b:
JASS:
function b
    local unit u = GetParameter(1)
    
    
    (set u = null)
endfunction
So yea you can use unit u, but it is a local varaible of function b.
the difference is that it is a parameter and parameters are automatically nulled at end. (that is something of JASS compiler)
 
Status
Not open for further replies.
Top