Snippet Game Time

Flare

Stops copies me!
Reaction score
662
Strictly speaking, shouldn't you be starting the timer at 0 seconds of game-time? If someone put the time on display in their game, it'd appear to be a few seconds ahead of the actual start time (e.g. displayed value at 0 seconds of game-time could be 5) since the timer would be started while the loading screen was still present

Just did a quick test on a new map. Event was 'Elapsed game time is 0.00 seconds', and GameTime_Get () returned 0.063 and, for what it's worth, the code
Code:
Zero Sec
    Events
        Time - Elapsed game time is 0.00 seconds
    Conditions
    Actions
        Custom script:   call BJDebugMsg ("Event is Elapsed game time is 0.00 seconds, supposed elapsed time is " + R2S (GameTime_Get ()))
:p

Doesn't seem like a big thing there, but if you put the system into an existing map with alot of content, the discrepancy could be much bigger
 
Reaction score
333
Jesus4Lyf, you are right that they are 32 bit, but wc3 has stuff in the background "for reals only" that allows them to go up to mega sizes, and I have yet to find a limit : ).

Maximum value for reals is somewhere between 10^38 and 10^39. You won't be able to get any finite value larger than 10^39.
 

Nestharus

o-o
Reaction score
84
That's good to know damien. I think I went up to 10^30 and 10^-30 and just assumed that at that point it could go wildly high ;P.

It's too bad that the performance hit is so massive as you go up tho, and it's also too bad that you can't directly assign those values to the variable =|.
 
Reaction score
333
That's good to know damien. I think I went up to 10^30 and 10^-30 and just assumed that at that point it could go wildly high ;P.

It's too bad that the performance hit is so massive as you go up tho, and it's also too bad that you can't directly assign those values to the variable =|.

What performance hit is this? I'm no expert in floating point math but I assumed the performance would be more or less consistent. Do we have benchmarks for this?
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Why the hell a dynamic trigger is needed here ?

You can just increment a global integer each time the timer expire.

Also according to Vexorian a such period will be horribly inaccurate :
http://www.wc3c.net/showpost.php?p=1085942&postcount=10

EDIT :
Aha got it more "efficient" when you read the elapsed time, like a such one does matter xD

Anyway if you want to be accurate you don't have really the choice.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
A dynamic trigger is needed to start the timer at 0 seconds instead of map init.
Ok, but you still don't need a global variable, you can use GetTriggeringTrigger() instead and a local one inside the init function.

>Also according to Vexorian a such period will be horribly inaccurate
The timeout on this simply doesn't matter. Furthermore, how is being "0.007" out horribly inaccurate?
Yes you're right it isn't "horribly".
 

Azlier

Old World Ghost
Reaction score
461
Am I missing something, or will
JASS:
private function StartGameTime takes nothing returns nothing
    call TimerStart(runGameTime, gameTime, false, null)
endfunction
    
private function Initialization takes nothing returns nothing
    call TimerStart(runGameTime, 0, false, function StartGameTime)
endfunction

not work the same, if not better, than the dynamic trigger solution?
 

Jesus4Lyf

Good Idea™
Reaction score
397
Am I missing something, or will
JASS:
private function StartGameTime takes nothing returns nothing
    call TimerStart(runGameTime, gameTime, false, null)
endfunction
    
private function Initialization takes nothing returns nothing
    call TimerStart(runGameTime, 0, false, function StartGameTime)
endfunction

not work the same, if not better, than the dynamic trigger solution?
Genius. I was thinking of using a dynamic timer instead of trigger but that didn't make sense. Lol...
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
It seems this solution is pointless, test this code :

JASS:
library Test initializer init

globals
    private timer Tim
    private timer T2
endglobals

private function Actions takes nothing returns nothing
    call TimerStart(T2,10.,false,null)
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerAddAction(trig, function Actions)
    call TriggerRegisterTimerEvent(trig,0.,false)
    
    set Tim = CreateTimer()
    set T2 = CreateTimer()
    call TimerStart(T2,0.,false,function Actions)
    call TimerStart(Tim,10.,false,null)
    
    call TriggerSleepAction(5.)
    call BJDebugMsg(R2S(TimerGetElapsed(Tim) * 100000.))
    call BJDebugMsg(R2S(TimerGetElapsed(T2) * 100000.))
endfunction

endlibrary


Simply start the timer one time should be enough.

Tested on an other-random-aos-that-fuck-up-your-mouse with a 9-10 seconds of loading and the difference between the two elapsed is irrelevant and probably just because 0. is not truly instant and also calling BJDebugMsg takes a few time to be done.
It seems timers start by themselves only when the loading is finished, and that makes sense.

In fact that's why i said a dynamic trigger is useless, and now i'm sure of that, blame you to make me doubtful :p
 

Sim

Forum Administrator
Staff member
Reaction score
534
Well, first of all this is a snippet, not really a system.

> MFN had like... 15 plugins... so get ready for a torrent of submissions ><

Why not find something they have in common and try to unite them?
 

UndeadDragon

Super Moderator
Reaction score
447
Any reason why the function is called GameTime_Get(), rather than GetGameTime(). To me it seems more logical to call it GetGameTime().
 

Vexorian

Why no custom sig?
Reaction score
187
The constant keyword makes no difference after compiled to bytecode, it does not exist in the bytecode, it does nothing speed-wise.

It is more of a language feature, like setting the global as read-only, and in the case of functions, it means the function will always return the same thing after you give it the same arguments, unfortunately, this has been implemented very poorly, because you can do things like set inside constant functions, and there are many natives that are DEFINITELY not constant, yet they have that keyword.

The only use for the constant keyword is when the optimizer tries to inline them. As for constant functions, they used to be useful only when you wanted the optimizer to inline them. Nowadays they aren't that much as jasshelper can inline even non-constant functions, and it turns out "constant" gives little to no guarantee about a function being inline friendly.
 

Nestharus

o-o
Reaction score
84
JASS:
private function StartGameTime takes nothing returns nothing
    call TimerStart(runGameTime, gameTime, false, null)
endfunction
    
private function Initialization takes nothing returns nothing
    call TimerStart(runGameTime, 0, false, function StartGameTime)
endfunction

I remember a long time ago that when I'd start a timer, it wouldn't start properly unless started after loading. I used this while making it and didn't think to do a quick test on starting a timer before loading : ).

I'll be updating it to use this format right now : ).

Finally, everyone prefers the normal JASS style of things like GetElapsedGameTime, so the function name changed to that : ). I normally work in a more OO environment, so it's more natural for me to do things like GameTime.GetElapsed(), =).
 

Romek

Super Moderator
Reaction score
963
Changed from [System] to [Snippet]

The naming of the global timer does bug me, though it's private anyway, so meh. Nobody will know about it.

Anyway, approved.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top