Jump to content

counter


yucatan
 Share

Recommended Posts

Hello guys i'm using this script to count from 10 to zero.

i wanne make it like this that if it reaches 10 that the counter restart.

but i dont know how i need to do that.

some help Pleas?

Thanks alot.

$count_down_time = 1 ;sec
$corected_time = $count_down_time * 1000
$timer = TimerInit()
Global $display_old


while 1
    $display = Floor(($corected_time-TimerDiff($timer))/1000)
    if $display <> $display_old Then
      ConsoleWrite($display&@CRLF)
        $display_old = $display
    EndIf
;~  == end of display countdown part ===
    if TimerDiff($timer)>= $corected_time Then
        exit
    EndIf
WEnd
Link to comment
Share on other sites

Something like this?

$count_down_time = 1 ;sec
$corected_time = $count_down_time * 1000
$timer = TimerInit()
Global $display_old
Global $counter = 0

While 1
    $counter += 1
    
    $display = Floor(($corected_time - TimerDiff($timer)) / 1000)

    If $display <> $display_old Then
        ConsoleWrite($display & @CRLF)
        $display_old = $display
    EndIf

;~  == end of display countdown part ===
    If TimerDiff($timer) >= $corected_time Then
        Exit
    EndIf
    
    If $counter = 10 Then 
        $COunter = 0
    EndIf
WEnd

Edit* DOH! I forgot to count down from ten.

Edited by jaberwocky6669
Link to comment
Share on other sites

script is the same....

it needs to count down from 5 to 0

if it has reaches 0 then start again from 5 to 0/

Like this ?

$timer = TimerInit()
Global $display_old=1

while 1
    $display = Floor ( TimerDiff ( $timer ) )
    If $display <> $display_old Then
        ConsoleWrite(5-$display&@CRLF)
        $display_old = $display
    EndIf
;~  == end of display countdown part ===
    If TimerDiff($timer)> 5 Then
        $timer = TimerInit()
    EndIf
WEnd
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

timer goes much to fast.

it count down but not every second.

Sorry it was milliseconds, now it's seconds ! Posted Image

$timer = TimerInit()
Global $display_old=1

while 1
    $display = Floor ( TimerDiff ( $timer )/1000 )
    If $display <> $display_old Then
        ConsoleWrite(5-$display&@CRLF)
        $display_old = $display
    EndIf
    If TimerDiff($timer)/1000 > 5 Then $timer = TimerInit()
WEnd
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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...