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

[JASS] scope does not work

Status
Not open for further replies.
Level 9
Joined
Dec 13, 2005
Messages
102
I don't know why, this trigger won't work:

scope HeroDone initializer Init

//****************************************************

private function act takes nothing returns nothing
call TimerDialogDisplay(udg_HeroPickTimerWin, false)
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "TIME OUT")
endfunction

//****************************************************

private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddAction(t, function act)
call TriggerRegisterTimerExpireEventBJ(t, udg_HeroPickTimer)
endfunction

endscope



While this trigger runs normally:

function Hero takes nothing returns nothing
local unit u
local real X
local real Y
local integer i=0
call TimerDialogDisplay(udg_HeroPickTimerWin, false)
call DisplayTextToPlayer(Player(0), 0, 0, "TIME OUT")

set u = null
endfunction

//****************************************************

function InitTrig_HeroDone takes nothing returns nothing
set gg_trg_HeroDone = CreateTrigger()
call TriggerRegisterTimerExpireEventBJ(gg_trg_HeroDone, udg_HeroPickTimer)
call TriggerAddAction(gg_trg_HeroDone, function Hero)
endfunction
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
The initializer probably fires before the timer is created unlike the normal one which is after. If so, this is due to how Vjass compiles initializers.

The timer event looks at the contense of the variable, and not the variable itself. As such if it contains no timer or a different timer, it will not work when you eventually start the timer.
 
Status
Not open for further replies.
Top