Can I pass local variable values to other functions?

Rainther

I guess I should write something of value here...
Reaction score
61
Not really. Unless you mean sending it like:
JASS:
local real LawL = 600
call CustomFunction(LawL)
 

Lightstalker

New Member
Reaction score
55
Not really. Unless you mean sending it like:
JASS:
local real LawL = 600
call CustomFunction(LawL)

What I want to do is pick all units owned by player 5 and give shared vision of those units to the owner of the triggering unit (which is an array variable).
 

Rainther

I guess I should write something of value here...
Reaction score
61
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.
 

Lightstalker

New Member
Reaction score
55
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.

No I have 2 functions:

JASS:
call GroupEnumUnitsOfPlayer(TEMPGROUP, Player(11), Condition(function SharedVision))


Which calls this function:

JASS:
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
 

Rainther

I guess I should write something of value here...
Reaction score
61
I'm not sure how much you can do in filter functions, I usually take all units and handle them from an unit group.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
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
 

Lightstalker

New Member
Reaction score
55
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

Don't I need to remove the unit from the group or something?
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
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.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Clear, no. Destroy, yes. Unless you're using a global group that is.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top