HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

vJass & Timers

09-26-2007, 09:41 AM#1
Av3n
Im just wondering if you can do something like this
call TimerStart(timer,0.1,true,method call)
I couldn't be bothered to read the manual right now

-Av3n
09-26-2007, 09:48 AM#2
Silvenon
You mean something like this?

Collapse JASS:
struct ExampleStruct
    method DoSomething takes nothing returns nothing
        call DoSomething
    endmethod
endstruct

function ExampleFunc takes nothing returns nothing
    local ExampleStruct es = ExampleStruct.create()
    local timer t = CreateTimer()
    call TimerStart(t, 0.1, true, es.DoSomething())
    set t = null
endfunction

If this example shows what you wanted to ask, then yes, you can do that.
09-26-2007, 10:22 AM#3
Hitchhiker
I thought you can only call static methods taking nothing via callbacks
Collapse JASS:
struct A
    static method func takes nothing returns nothing
        call something()
    endmethod
endstruct

function test takes nothing returns nothing
    //somecalls...
    call TimerStart(t, 1., true, function A.func)
    //some other calls...
endfunction
09-26-2007, 01:01 PM#4
Vexorian
Hitchhiker is right.

Try using TimeLib ... You can just use any typical attach system, attach integer(structvalue) and then when reading use structvalue( storedinteger).
09-26-2007, 01:07 PM#5
Toink
Collapse JASS:
        if (N==0) then
            debug call BJDebugMsg("Warning: Event Lib expires with no event")
            return 
        endif

        // [0] has expired...
        if ((events[0].stop) or (events[0].onExpire()) ) then
            call events[0].destroy()
        endif

        // Reheap the stuff...
        set N=N-1
        set i=0
        if (N==0) then
            //nothing to do here.
           return 
        endif

You would be desyncing Mac users with those lines :p
09-26-2007, 01:18 PM#6
Vexorian
so, you think that not returning a boolean on timer expire functions would desync mac players?
09-26-2007, 01:24 PM#7
Toink
I recall seeing something like that awhile ago, I'll try to look for it.

EDIT: Found it, I don't know much of these stuff so I'm trying to find out more about them :p

Quote:
Originally Posted by cohadar
One of the main reasons of map desyncs is people who do this:

Collapse JASS:
function Trig_MacDesync_Conditions takes nothing returns nothing
    // Conditions must return boolean, not nothing ffs
    // also if you forget to do a return false or return true
    // and simple let condition end without a return it will desync MAC users
    
    return   // << -- no true, no false == desync
endfunction

// jasshelper versions before 0.9.9.2 all have this desync


function Trig_MacDesync_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_MacDesync takes nothing returns nothing
    set gg_trg_MacDesync = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_MacDesync, Condition( function Trig_MacDesync_Conditions ) )
    call TriggerAddAction( gg_trg_MacDesync, function Trig_MacDesync_Actions )
endfunction
09-26-2007, 01:28 PM#8
Vexorian
Quote:
so, you think that not returning a boolean on timer expire functions would desync mac players?
09-26-2007, 01:29 PM#9
Toink
09-26-2007, 06:12 PM#10
botanic
also cohadar posted that and while he may not be a bad coder him and a few other people (including me) are not always right. There are normally exceptions to EVERY rule in JASS (due to bugs or w/e) so take everything with a grain of salt. Cept maby vex and a few other people who masochistically pour over there code for bugs ect :P
09-26-2007, 07:47 PM#11
Silvenon
Vex, what exactly is that TimeLib thingy and how do you use it? I heard about it a couple of times, but I never bothered to find out what exactly is it. Maybe add a description under that code?
09-26-2007, 08:10 PM#12
cohadar
Well it is an alternative method to attaching stuff to timers.
Instead of attaching it uses array and a heap algorithm.
09-26-2007, 10:43 PM#13
Vexorian
Quote:
Originally Posted by Silvenon
Vex, what exactly is that TimeLib thingy and how do you use it? I heard about it a couple of times, but I never bothered to find out what exactly is it. Maybe add a description under that code?
If you ask me, you shouldn't bother with TimeLib, the magictimer thing I am making right now is cooler ...
09-26-2007, 10:54 PM#14
botanic
well Vex sorry to break it to ya but it isnt finished yet :P
09-26-2007, 11:17 PM#15
Av3n
Thx for the info, i needed to run with 2 timers(shield regeneration(secondary timer(local)),shield health(main timer(global))) for a spell or something simliar thx.

-Av3n