Jump to content

Why is this timer not possible?


bald1
 Share

Recommended Posts

Hey fellow nerds!

Im really just looking for a workaround, since what i wanted doenst seem possible :)

This is what i thought was possible and wanted:

local $vEvent01 = 3000
local $vEvent02 = 5000

Local $vTimer01 = TimerInit()
Local $vTimer02 = TimerInit()


while 1 = 1
    Select
        Case $vTimer01 > $vEvent01
            ;.. something something darkside action
        Case $vTimer02 > $vEvent02
            ;.. something something darkside action
    EndSelect
sleep(1000)
WEnd

I bet you all see what i wanted with this. Is there something obvious I dont see, or how come i cant use this function in this manner? What could be a workaround? :)

Link to comment
Share on other sites

TimerInit returns the current time stamp in milliseconds from a set time. For example: 123899786123

Read the comments:

local $vEvent01 = 3000
local $vEvent02 = 5000

Local $vTimer01 = TimerInit() ; <= $vTimer01 is now 123899786123
Local $vTimer02 = TimerInit() ; <= $vTimer02 is now 123899786125


while 1 = 1
    Select
        Case $vTimer01 > $vEvent01 ; Case 123899786123 > 3000 ... Hehe, surely that's not what you meant :D
            ;.. something something darkside action
        Case $vTimer02 > $vEvent02
            ;.. something something darkside action
    EndSelect
sleep(1000)
WEnd

TimerDiff($vTimer01), which is a AutoIt native function, does this:

Func TimerDiff($timestamp)
   Return TimerInit() - $timestamp
EndFunc

Case TimerDiff($vTimer01) > $vEvent01 ; Case 1023 > 3000 .. This is right. : )

Please enjoy this piece of free information by a fellow nerd. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...