Function parameters

ThePlague

New Member
Reaction score
14
When I make a unit group...
the condition function can take local variables right? Does this still work for the function I use for the actions?

Oh also what are the commands concerning local variable matrices?
 

Tom Jones

N/A
Reaction score
437
Local variables are local for a function, they can't be accessed outside the function. Etc.:
JASS:
function whatever takes nothing returns boolean
    return GetUnitTypeId(u) == 'Hamg' //Syntax error, undeclared variable
endfunction

function ...
     local unit u = GetTriggerUnit()
     
     if whatever then
         call BJDebugMsg("This message shouldn't be displayed")
     endif
endfunction


This means that
the condition function can take local variables right? Does this still work for the function I use for the actions?
no, a callback function can't acces the calling functions locals. They can however acces event responses, such as GetTriggerUnit(). This is for example perfectly legal:
JASS:
function KillTriggerUnit takes nothing returns nothing
    call KillUnit(GetTriggerUnit())
endfunction

function ...
    call KillTriggerUnit()
endfunction
 

ThePlague

New Member
Reaction score
14
wait...When can you use the 'takes' parameter then?
I thought you could for functions being used by ForGroupBJ(group, function)
Would basic variables be able to be taken? (integers, reals, booleans)



P.S. I solved the problem. Found a diff way to reference variable I wanted.

uhh also is there direct a way to determine the level of a buff that is affecting a unit?
 

Tom Jones

N/A
Reaction score
437
a) A function may have parameters as longs as it isn't used as a callback function.
b) GetUnitAbilityLevel(someunit,buffid)
 

ThePlague

New Member
Reaction score
14
GetUnitAbilityLevel() works for buffs? cool, trying now
thx for help +rep

edit: actually i gave you rep earlier now i cant :(
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top