• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[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
 
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.
Back
Top