Jump to content

Restart Function


crzftx
 Share

Recommended Posts

I understand that there is another similar post about a function that restarts the code, but it is a bit different and not answered. I have a simple game and I want it to start over when I press F2. I want a function set from HotKeySet (any alternatives to HotKeySet other than AdlibEnable with _IsPressed??) that would restart the code from a certain spot, or the beginning, if nothing else is possible. I could easily do this if Goto was still around, but it's not. Any suggestions?

Link to comment
Share on other sites

What if you litterally make it 'restart' the game, close it and open it again?

If it really is a simple game, you could move all the objects back where they were and set scores etc to 0... but we dont know what it is yet

Link to comment
Share on other sites

maybe something like this:

Global $nRestartCount = 0
_Main($nRestartCount) ;Call the main function

Func _Main($nRestartCountW)
    ;We do our main code in here
    MsgBox(0, "Program Restart Count", $nRestartCountW)
    $hWnd = GUICreate("MyTitle")
    GUISwitch($hWnd)
    $nMyButton = GUICtrlCreateButton("Restart Script", 0, 0, 100)
    GUISetState()
    While (1)
        $uMsg = GUIGetMsg()
        if ($uMsg == -3) then ExitLoop
        if ($uMsg == $nMyButton) Then 
            $nRestartCount += 1
            GUIDelete($hWnd)
            _Main($nRestartCount)
        EndIf
    WEnd
    Return 0    
EndFunc
oÝ÷ Úâ*.­Æ¬y«­¢+Ø)!½Ñ-åMÐ ÅÕ½ÐííÕôÅÕ½Ðì°ÅÕ½Ðí}5¥Ñ½ÈÅÕ½Ðì¤)±½°ÀÌØí¹IÍÑÉÑ
½Õ¹ÐôÀ)±½°ÀÌØí¡]¹ôÀ)}5¥¸ ÀÌØí¹IÍÑÉÑ
½Õ¹Ð¤í
±°Ñ¡µ¥¸Õ¹Ñ¥½¸()Õ¹}5¥¸ ÀÌØí¹IÍÑÉÑ
½Õ¹Ñ¤($í]¼½Õȵ¥¸½¥¸¡É(%5Í    ½à À°ÅÕ½ÐíAɽɴIÍÑÉÐ
½Õ¹ÐÅÕ½Ðì°ÀÌØí¹IÍÑÉÑ
½Õ¹Ñ¤($ÀÌØí¡]¹ôU%
ÉÑ ÅÕ½Ðí5åQ¥Ñ±ÅÕ½Ðì¤(%U%MÝ¥Ñ  ÀÌØí¡]¹¤($ÀÌØí¹5å    ÕÑѽ¸ôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½ÐíIÍÑÉÐMÉ¥ÁÐÅÕ½Ðì°À°À°ÄÀÀ¤(%U%MÑMÑÑ ¤(%]¡¥± Ĥ($$ÀÌØíÕ5ÍôU%Ñ5Í ¤($%¥ ÀÌØíÕ5Íôô´Ì¤Ñ¡¸á¥Ñ1½½À($$í¥ ÀÌØíÕ5ÍôôÀÌØí¹5å  ÕÑѽ¸¤Q¡¸M¹ ÅÕ½ÐííÄÉôÅÕ½Ðì¤(%]¹(%IÑÕɸÀ$)¹Õ¹()Õ¹}5¥Ñ½È ¤($ÀÌØí¹IÍÑÉÑ
½Õ¹Ð¬ôÄ(%U%±Ñ ÀÌØí¡]¹¤(%}5¥¸ ÀÌØí¹IÍÑÉÑ
½Õ¹Ð¤)¹Õ¹
Edited by CHRIS95219
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...