Jump to content

pause a loop?


Recommended Posts

im trying to make a hot key command to pause a loop or the script itself is it possible?

i have a "while" loop running and i have this so far:

HotKeySet("^!p", "pause")
Func pause()
[what goes here?]
EndFunc

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

im trying to make a hot key command to pause a loop or the script itself is it possible?

i have a "while" loop running and i have this so far:

HotKeySet("^!p", "pause")
Func pause()
[what goes here?]
EndFunc

HotKeySet("^!p", "pause")
Func pause()
sleep (time you would like to wait in miliseconds);[what goes here?]
EndFunc

:whistle:

Edited by azeazezar
Link to comment
Share on other sites

wait what if they wanted it to UN pause? would they have to just wait for it?

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

How about

HotKeySet("^!p", "_Pause")
$Paused = 0

;Code here

Func _Pause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
    WEnd
EndFunc

To be able to toggle pause with the hotkey.

EDIT: Got beat to it >.<

Edited by Vivvic

[quote name='DaleHohm']You have a strange habit of posting error messages that don't match your code.[/quote][quote name='SmOke_N']Forget the learning... straight to the scripting :lol: (laugh.gif)[/quote]

Link to comment
Share on other sites

Dim $sleep = 0
HotKeySet("{DEL}", "_Sleep")
While $sleep = 1
    If $sleep = 0 Then ExitLoop
    Sleep (100)
WEnd
Func _Sleep()
    If $sleep = 0 Then
        $sleep = 1
    Else
        $sleep = 0
    EndIf
EndFunc

idk if what they said works but this will

Link to comment
Share on other sites

straight from help "HotKeySet" AT THE BOTTOM of the page are great examples

; Press Esc to terminate script, [color="#ffffff"]Pause[/color]/Break to "[color="#ffffff"]pause[/color]"

Global $Paused
HotKeySet("{[color="#ffffff"]PAUSE[/color]}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")   ;Shift-Alt-d

;;;; Body of  program would go here ;;;;
While  1
    Sleep(100)
WEnd
;;;;;;;;

Func  TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is  "Paused"',0,0)
    WEnd
     ToolTip("")
EndFunc

Func  Terminate()
    Exit 0
EndFunc

Func  ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

8)

NEWHeader1.png

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