Sign in to follow this  
Followers 0
straysweeper

Trouble with TimerDiff inside an Array

3 posts in this topic

#1 ·  Posted (edited)

I'm not sure if this is doable or not but what i'm trying to do is create a countdown timer for multiple timers to then run a 'reset' function.

#include <Timers.au3>


Global $rounds
Global $A, $C
Global $Timer_Count[10]
Global $Timer_I[10]

$rounds = Inputbox("Number of rounds", "How many")



For $A = 1 To $rounds
    
    $Timer_Count[$A] = Inputbox("Question" & $A, "How many seconds" & $A & "?") * 1000
    
    _SetTimers($A)
    
    
    
Next

AdlibRegister("_AllTimers",500)

Func _SetTimers($countT)
    Local $nTime
    $Timer_I[$countT] = _Timer_Init()
    ;Msgbox(4,"Called Timer " & $countT, "This Timer was started " & $Timer_I[$countT])
    
    Return  
EndFunc

Func _AllTimers()
     

 Local $AT_gTimer, $AT_dTimer, $AT_sTimer
 
    
For $C = 1 To $rounds
$AT_dTimer = _Timer_Diff($Timer_I($C))
$AT_gTimer = $Timer_Count[$C] 

If $ATdTimer >= $AT_gTimer Then MsgBox(0,"TIME TO BUILD AGAIN!", "YOUR ALMOST THERE" & $C " Timer is up")

Next

    
EndFunc


While 1 
    Sleep(5000)
WEnd

Right now its creating a Error setting the Timer Diff of the Array.

Edited by straysweeper

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you have tupo in there

$AT_dTimer = _Timer_Diff($Timer_I($C))
;change to
$AT_dTimer = _Timer_Diff($Timer_I[$C])

did not tested rest of code, to answer your question, its doable.

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

... for multiple timers ...

straysweeper, you seem to have the wrong idea about timers.

So just to be sure. _Timer_Diff(), or TimerDiff() for that matter, just return the current cpu-tick value.

There not creating some special timer objects. -> as in something that has to be created separably if you like to have more of them.

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
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
Sign in to follow this  
Followers 0