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

[JASS] I'm really not quite sure.

Status
Not open for further replies.
Level 3
Joined
Jan 24, 2015
Messages
26
Been a bit since I last dipped in JASS, and I've run into an error and I'm not sure why.

JASS:
function PolledWaitFix takes real duration returns nothing
    local timer t
    local real  timeRemaining
    if (duration > 0) then
        set t = CreateTimer()
        call TimerStart(t, duration, false, null)
        loop
            set timeRemaining = TimerGetRemaining(t)
            exitwhen timeRemaining <= 0
            if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
        call DestroyTimer(t)
        set t = null
    endif
endfunction

function Trig_Tree_Respawn_Filter takes nothing returns boolean
    if (IsUnitType(GetEnumUnit(), UNIT_TYPE_FLYING) == TRUE) then
        return false
    endif
    if (IsUnitType(GetEnumUnit(), UNIT_TYPE_DEAD) == TRUE) then
        return false
    endif
    return true
endfunction

function Trig_Tree_Respawn_Actions takes nothing returns nothing
    local destructable Tree = GetTriggerDestructable()   
    local real TreeX = GetDestructableX(Tree) 
    local real TreeY = GetDestructableY(Tree)
    local group Units
    local integer UnitCount
    
    call PolledWaitFix( 300.00 )
    loop
        set Units = CreateGroup()
        set UnitCount = CountUnitsInGroup(GroupEnumUnitsInRange(Units, TreeX, TreeY, 128.0, function Trig_Tree_Respawn_Filter()))
        exitwhen UnitCount == 0
        call DestroyGroup(Units)
        call TriggerSleepAction(1.0)
    endloop 
    call DestroyGroup(Units)
    call DestructableRestoreLife( Tree, GetDestructableMaxLife(Tree), true )
endfunction

//===========================================================================
function InitTrig_Tree_Respawn takes nothing returns nothing
    set gg_trg_Tree_Respawn = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Tree_Respawn, function Trig_Tree_Respawn_Actions )
endfunction

The error is "Expected '", pointing at the set UnitCount = line.

I'm not entirely sure if the trigger works in the first place, because I'm not entirely sure what my script error is. Anyone more familiar with the language able to pick out what I'm doing wrong?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
When you are calling a function that takes code:
function f takes code c returns nothing
You call the function like this:
call f(function f2)
You have called it like this:
call f(function f2())
So if you remove those two, then you are fine.
 
Status
Not open for further replies.
Top