• 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 called functions...Help please

Status
Not open for further replies.
Hi.. I've a mix of Triggers and Jass, that still the problem I think.
with call StartTimer(t,0.001,function ANY) the function will not been executed.
I thought my syntax is right?!.
Or do I need to add the Event (A timer expires) to the function?
Also how to set global variables? I know that there is a GLOBAL part at the beginning of the map, but when you did it first in GUI and place on the first lines in your map, it still says its not the global part?! :S (Jass Helper)

HOw can I convert each trigger in the wc3 jass script? (Without converting every single one and copying it to the main script)

Is there any way?
 
Level 11
Joined
Feb 18, 2004
Messages
394
JASS:
native TimerStart takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing

Its TimerStart() not StartTimer()


If you're using NewGen, you can declare globals anywhere with this syntax:
JASS:
globals
    type name = value
    integer MyInt = 42
    unit SomeUnit
endglobals

And the hell do you mean by:
HOw can I convert each trigger in the wc3 jass script? (Without converting every single one and copying it to the main script)
 
Level 11
Joined
Feb 18, 2004
Messages
394
MUI just means that you will never have conflicts between different unique entities. (Spell casts, units, etc.) If you have a single global variable like:
JASS:
globals
    unit TargetUnit
endglobals

and you set it every time a spell is cast, then try to use it in a timer callback, then you loose MUI. This is because if you cast the spell again before the first timer expires, the variable is overwritten with the value from the second spell cast. When the first timer expires, it will use the new value in the variable, which is not the wanted value; its the value from the second spell cast.


Why the heck would you want to:
#1: use converted GUI code
#2: merge a bunch of converted GUI code in to one big ugly mess?
 
I need a full MUI castable spell with timers :S.

Its for an contest, because the triggers (which where made for the contest and are not changeable) are in GUI.... I hate GUI and JASS mix, so that would be better to have one singel jass script :S

Edit: I use Jass NewGen Pack

Edit2: I don't need a spell, I just need to know how to make a timer which calls a function which function has vlaues of the other function which started the timer.
 
Last edited:
Level 40
Joined
Dec 14, 2005
Messages
10,532
An example of how to pass data through a timer (pretend your spell is called FrostNova):

[jass=Gamecache library]library GC initializer init
function H2I takes handle h returns integer
return h
return 0
endfunction
globals
gamecache GameCache
endglobals
private function init takes nothing returns nothing
call FlushGameCache(InitGameCache("gc.w3v"))
set GameCache = InitGameCache("gc.w3v")
endfunction
endlibrary[/code]

JASS:
struct FrostNovaData
    integer int
    unit u //these two vars are just data you could stick in your struct
endstruct

function TheSpell_Child takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local FrostNovaData dat = GetStoredInteger(GameCache,I2S(H2I(t)),"dat")
    //do stuff using dat, etc
    //don't forget to flush the integer when destroying the timer
endfunction

function TheSpell takes nothing returns nothing
    local FrostNovaData dat = FrostNovaData.create()
    local timer t = CreateTimer()
    //store stuff to dat's values
    call StoreInteger(GameCache,I2S(H2I(t)),"dat",dat)
    call TimerStart(t,.01,true,function TheSpell_Child)
endfunction
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
Tip: You cant put TriggerSleepAction-PolledWait(not sure about polled) in timer functions
it just doesnt work. No logical reasons
 
Status
Not open for further replies.
Top