• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Timer Window Issue

Status
Not open for further replies.
Level 16
Joined
Mar 3, 2006
Messages
1,564
I created a timerdialog for a one shot timer that expires in 6 seconds.

My system requires that I pause and start the timer as much as needed (i.e. reset the timer) no problem with the timer itself but the problem is in the timer window, which is: I paused the timer and there was 2 seconds remaining then when I start it again the window counted from 6 as normal but when this 6 seconds expired the window showed 2 seconds and whenever the timer start it counts from 6 to 0 then go back to 2.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Here is the code, but I might not be able to post more so that this system can be approved when I finish it.

JASS:
// dummy comment to indent the following line

    function endCombatState takes nothing returns nothing
        call MultiboardSetItemValueBJ( bj_lastCreatedMultiboard, 2, 1, I2S(CombatCounter))
        call MultiboardSetItemValueBJ( bj_lastCreatedMultiboard, 2, 2, "|cff00FF00Out of Combat|r" )
        /* Combat state boolean variable must be set here */
    endfunction

    function In_Actions takes nothing returns boolean
        call PauseTimer(reset_timer)
        call MultiboardSetItemValueBJ( bj_lastCreatedMultiboard, 2, 1, I2S(CombatCounter))
        call MultiboardSetItemValueBJ( bj_lastCreatedMultiboard, 2, 2, "|cffFF0000In Combat|r" )
        /* Combat state boolean variable must be set here */
        return false
    endfunction

    function Out_Actions takes nothing returns boolean
        local trigger this = GetTriggeringTrigger()
        call DisableTrigger( this )
        if CombatCounter < 0 then
            set CombatCounter = 0
        endif
        call TimerStart(reset_timer,reset_period,false,function endCombatState)
        call EnableTrigger( this )
        return false
    endfunction

    function initCSS takes nothing returns nothing
        call TriggerRegisterVariableEvent  ( In , "CombatCounter",      GREATER_THAN, 0 )
        call TriggerRegisterVariableEvent  ( Out, "CombatCounter",LESS_THAN_OR_EQUAL, 0 )

        call TriggerAddCondition(In , Condition( function  In_Actions ) )
        call TriggerAddCondition(Out, Condition( function Out_Actions ) )
    endfunction
Multiboard function are just there for testing the system in-game and will be removed once the system is done.

______
_EDIT_

Here is what I concluded, if you pause a timer then start it again till it expire the window get updated to the previous time that the timer was paused.


________
_EDIT 2_
Maybe try create a new timer window each time you start the timer?
Not working, try the attached map and you will understand what the problem is. But make sure to pause the first timer and don't let it expire.

That is the only function I found that can fix this problem:

native TimerDialogSetRealTimeRemaining takes timerdialog whichDialog, real timeRemaining returns nothing

However, there is only a small issue, which is setting timeRemaining to 0, this causes the "0:00:00" displayed in the window to disappear only the title remains, if any, but if timeRemaining is set to 0.001 (small real) you will get the "0:00:00". And OFC you will have to update the window again when the timer start and set timeRemaining to the timer's time-out.

call TimerDialogSetRealTimeRemaining(bj_lastCreatedTimerDialog,0.001)

call TimerDialogSetRealTimeRemaining(bj_lastCreatedTimerDialog,6.)
 

Attachments

  • timertest.w3m
    16 KB · Views: 38
Last edited:
Status
Not open for further replies.
Top