Lightstalker
New Member
- Reaction score
- 55
Pretty self-explanatory title.
Can I pass local variable values to other functions?
Can I pass local variable values to other functions?
Not really. Unless you mean sending it like:JASS:local real LawL = 600 call CustomFunction(LawL)
And you can't do all of this in one function?
You could set all of them to a unit group instead.
Sending arrays through functions demands structs if I'm not mistaken.
call GroupEnumUnitsOfPlayer(TEMPGROUP, Player(11), Condition(function SharedVision))
private function SharedVision takes nothing returns boolean
local unit u = GetFilterUnit()
local player p = GetOwningPlayer(u)
local player ally = GetOwningPlayer(HERO[pid]) //pid NOT A LOCAL. GIVES ERRORS.
local integer i = 0
if IsPlayerAlly(p, ally) then
call UnitShareVision(u, ally, true)
endif
set u = null
return false
endfunction
I'm not sure how much you can do in filter functions, I usually take all units and handle them from an unit group.
private function True takes nothing returns boolean
return true
endfunction
private function Actons takes nothing returns nothing
local group g = CreateGroup()
local unit u
call GroupEnumUnitsOfPlayer(g, Player(4), Filter(function True))
loop
set u = FirstOfGroup(g)
exitwhen u == null
//Do whatever is to be done in your filterfunction
endloop
endfunction
A FirstofGroup() loop would be an easy way if you're uncertain in how to pass whatever variables you need to pass. Something like this:
JASS:private function True takes nothing returns boolean return true endfunction private function Actons takes nothing returns nothing local group g = CreateGroup() local unit u call GroupEnumUnitsOfPlayer(g, Player(4), Filter(function True)) loop set u = FirstOfGroup(g) exitwhen u == null //Do whatever is to be done in your filterfunction endloop endfunction
That is done at the end of the loop. Instead of your regular "set i = i + 1" or something. Just remember to add it outside the filter ifs.