• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

More problems with TriggerSleepAction()

Status
Not open for further replies.
Level 6
Joined
Feb 12, 2008
Messages
207
Humm people, I know that the TriggerSleepAction() function isn't accurate below 0.27s. And I also know this question may be a little stupid but when I test the map, this piece of code just gives me almost a double floating text, one over the other, separated by an offset of somewhat near 10 on the Z axis. My question is, the 'call TriggerRegisterTimerEventPeriodic( gg_trg_LowStats, 10.00 )' and both 'call TriggerSleepAction(10)' run separately? I mean, am I getting a wait of 30s total or is it every 10s that the trigger is being run? I'm just getting mad with a stupid question but I can't seem to be able to make them show separately from each other.

The code is here:

JASS:
function CheckLowStats takes nothing returns nothing
 // Check if the Energy is low
 local integer i
 set i=0
 loop
    exitwhen (i>10)
    if ( udg_Status_Energy[i] <= 20.00 ) then
       call FloatingTxt("Im tired", udg_Survivor[i], 15, 15, 100)
    else
    endif
    set i=i+1
 endloop
 // Wait and check if the Hunger is low
 call TriggerSleepAction(10)
 set i=0
 loop
    exitwhen (i>10)
    if ( udg_Status_Hunger[i] <= 20.00 ) then
      call FloatingTxt("Im hungry", udg_Survivor[i], 70, 70, 0)
    else
    endif
    set i=i+1
 endloop
 // Wait again and check if the Heat is low
 call TriggerSleepAction(10)
 set i=0
 loop
    exitwhen (i>10)
    if ( udg_Status_Heat[i] <= 20.00 ) then
      call FloatingTxt("Im cold", udg_Survivor[i], 55, 55, 100)
    else
    endif
    set i=i+1
 endloop
endfunction

//===========================================================================
function InitTrig_LowStats takes nothing returns nothing
    set gg_trg_LowStats = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_LowStats, 10.00 )
    call TriggerAddAction( gg_trg_LowStats, function CheckLowStats )
endfunction

Any help would be appreciated. Thanks in advance :D

EDIT: Shit, I thought this was on the Triggers & Scripts section. If any mod comes by, please move it there. In the JASS section.
 
Last edited:
Level 6
Joined
Feb 12, 2008
Messages
207
I started with JASS about 3 or 4 hours ago, so if you could help me with those local timers I would really appreciate that. Thanks!
 
Level 9
Joined
Jan 3, 2010
Messages
359
hmm ...
maybe like this

JASS:
function CheckLowHeat takes nothing returns nothing
 local integer i = 0
 local timer time = CreateTimer()

 loop
    exitwhen (i>10)
    if ( udg_Status_Heat[i] <= 20.00 ) then
      call FloatingTxt("Im cold", udg_Survivor[i], 55, 55, 100)
    else
    endif
    set i=i+1
 endloop

endfunction

function CheckLowHunger takes nothing returns nothing
 local integer i = 0
 local timer time = CreateTimer()

 loop
    exitwhen (i>10)
    if ( udg_Status_Hunger[i] <= 20.00 ) then
      call FloatingTxt("Im hungry", udg_Survivor[i], 70, 70, 0)
    endif
    set i=i+1
 endloop
 // Wait again and check if the Heat is low
 call TimerStart(0.1, false, function CheckLowHeat)

function CheckLowEnergy takes nothing returns nothing
 // Check if the Energy is low
 local integer i = 0
 local timer time = CreateTimer()

 loop
    exitwhen (i>10)
    if ( udg_Status_Energy[i] <= 20.00 ) then
       call FloatingTxt("Im tired", udg_Survivor[i], 15, 15, 100)
    endif
    set i=i+1
 endloop
 // Wait and check if the Hunger is low
 call TimerStart(0.10, false, function CheckLowHunger)
endfunction

//===========================================================================
function InitTrig_LowStats takes nothing returns nothing
    set gg_trg_LowStats = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_LowStats, 10.00 )
    call TriggerAddAction( gg_trg_LowStats, function CheckLowEnergy )
endfunction

actually i'm still learning on JASS too :D
really sorry if i made a mistake :D
 
Level 6
Joined
Feb 12, 2008
Messages
207
just a couple of small mistakes like that u forgot the 2nd endfunction, but with some minor changes I can say now that you helped me in getting rid of those nasty and inaccurate waits! +rep for ur help :D
 
Status
Not open for further replies.
Top