"Wait for condition" issue

Arkan

Nobody rides for free
Reaction score
92
Example trigger:
GUI using a global variable:

Code:
Events: -
Condtions: -
Actions:
For each (Integer B) from 1 to 5, do (Actions)
    Loop - Actions
        Set i = (i + 1)
Wait until (i Equal to 5), checking every 0.20 seconds

Now I want to make the same thing in JASS using a local variable to make trigger MUI. So I convert the trigger to custom text and this si what I get:

Code:
function Trig_GUI_Func002001 takes nothing returns boolean
    return ( [B]udg_i[/B] == 5 )
endfunction

function Trig_GUI_Actions takes nothing returns nothing
    set bj_forLoopBIndex = 1
    set bj_forLoopBIndexEnd = 5
    loop
        exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
        set [B]udg_i [/B] = ( [B]udg_i[/B] + 1 )
        set bj_forLoopBIndex = bj_forLoopBIndex + 1
    endloop
    loop
        exitwhen ( Trig_GUI_Func002001() )
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.20))
    endloop
endfunction

//===========================================================================
function InitTrig_GUI takes nothing returns nothing
    set gg_trg_GUI = CreateTrigger(  )
    call TriggerAddAction( gg_trg_GUI, function Trig_GUI_Actions )
endfunction

Now as I've understood local variables can only be used within ONE single function, so how would I make wait for conditon work if I don't want to use a global variable?
Sorry I don't think I can explain any better than this :/
 

corvusHaunt

New Member
Reaction score
96
I don't see the point to that. The functions doesn't consider actions outside of the loop while it's running. So your "Wait for" will only even start after the loop is done, when the condition is already met. Useless or not, you don't need game cache for this.

Code:
function Trig_GUI_Actions takes nothing returns nothing
[COLOR=Navy]    local integer index = 1
    local integer i[/COLOR]
    loop
[COLOR=Navy]        exitwhen index > 5
      set i  =  i + 1[/COLOR]
        set index = index + 1
    endloop
    loop
        [COLOR=Navy]exitwhen i==5[/COLOR]
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.20))
    endloop
endfunction

//======================================================================  =====
function InitTrig_GUI takes nothing returns nothing
    set gg_trg_GUI = CreateTrigger(  )
    call TriggerAddAction( gg_trg_GUI, function Trig_GUI_Actions )
endfunction
 

emjlr3

Change can be a good thing
Reaction score
395
yeaur trigger makes no sense, as corvus said.....

u may be looking for something more like this
PHP:
local integer i=1

loop
    exitwhen i>5
    call TriggerSleepAction(.2)
    set i = i + 1
endloop
 

Arkan

Nobody rides for free
Reaction score
92
Ah yes, for some reason I thought for loops skipped wait actions, lol.
 

SFilip

Gone but not forgotten
Reaction score
634
only player/unit loops can get stopped by a wait.
 
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