• 🏆 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!

unit u inst stored in function b right?

Status
Not open for further replies.
Level 24
Joined
Aug 1, 2013
Messages
4,657
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