• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Timer failing to fire

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2013
Messages
1,105
Some backstory: I was having an issue with my libraries needing to reference each other.

Players select a scenario, a round starts, a round ends, Players select a scenario...etc

I was told about saving a code variable at initialization would allow this back and forth to be possible, and it is. However, I was recently changing some other things around and it ended up breaking.

The function StartRoundTimer does not fire at all, and I cannot seem to figure out the cause. Just in case I am unclear, view a basic example below.

Edit: If I change out the function to one within the library, or to one within a library that is required it will also work, but it seems to crash the thread for the one I am trying to access as no debug message display after the attempt to start the timer.

JASS:
       // Removed non pertinent code/vars that are currently commented.
library Winner requires Scenarios
            globals
         
        private constant timer t = CreateTimer()
        private timerdialog td = null
        private constant string TIMER_TITLE = "Round Ends..."
        code CODE_StartRoundTimer
         
            endglobals

    function StartRoundTimer takes nothing returns nothing
        call TimerStart(t, minutesPerRound, false, function RoundEnd1)
        if td == null then
            set td = CreateTimerDialog(t)
        endif
        call TimerDialogDisplay(td, true)
        call TimerDialogSetTitle(td, TIMER_TITLE)
    endfunction 

 
     private function init takes nothing returns nothing
        set CODE_StartRoundTimer = function StartRoundTimer
    endfunction

endlibrary

JASS:
       // Removed non pertinent code/vars that are currently commented.
library Scenarios
           globals
        timer ROUND_TIMER = CreateTimer()
           endglobals



    function StartScenario takes nothing returns nothing


        call TimerStart(ROUND_TIMER, ZERO, false, CODE_StartRoundTimer) // this should/does allow us to call StartRoundTimer in Winner despite Winner requiring Scenarios.

    endfunction

endlibrary

JASS:
library Other initializer init
    globals
 
    private timer t = CreateTimer()
 
    endglobals


function ForthAndBack takes nothing returns nothing
    call TimerStart(t, 0., false, codedTimer)


endfunction

function init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( t, Player(0), "test", true )
    call TriggerAddAction( t, function ForthAndBack )
    set t = null
endfunction

endlibrary

library Back initializer init requires Other

    globals
 
 
    private timer t = CreateTimer()
    code codedTimer
 
    endglobals


function myFunction takes nothing returns nothing
    call BJDebugMsg("Hello World")
endfunction


private function init takes nothing returns nothing
    set codedTimer = function myFunction

endfunction


endlibrary
 
Last edited:
Status
Not open for further replies.
Top