Jump to content
UBot Underground

Running Pause Loop In The Background


Recommended Posts

In my last bot I used the Stop Pause Check code and it worked fine. However the bot I am currently working on has a lot more going on and I am looking for something with a quicker response without having a million "Stop Pause Check" commands dropped everywhere my code.

 

First thought was to run a thread looping in the background checking for the change in the pause value. What I got from that was exactly what in hindsight I should have expected is that it stopped the background thread and did not touch the main thread. 

 

I tried a few other things, none of which worked. I found this as it seemed to be geared towards multiple threads but it did not work for me. 

http://www.ubotstudio.com/forum/index.php?/topic/12766-how-does-pause-script-and-stop-script-work/?p=69639

 

The bot itself i not using multiple threads (yet anyway) so with the one in the background there would be only two working. 

 

Any help would be great. 

 

Thanks

 

As an additional question what would be the best tutorials for multi-threading? Preferably one that assumes I do not have a clue. 

 

 

Link to post
Share on other sites

In my last bot I used the Stop Pause Check code and it worked fine. However the bot I am currently working on has a lot more going on and I am looking for something with a quicker response without having a million "Stop Pause Check" commands dropped everywhere my code.

 

First thought was to run a thread looping in the background checking for the change in the pause value. What I got from that was exactly what in hindsight I should have expected is that it stopped the background thread and did not touch the main thread. 

 

I tried a few other things, none of which worked. I found this as it seemed to be geared towards multiple threads but it did not work for me. 

http://www.ubotstudio.com/forum/index.php?/topic/12766-how-does-pause-script-and-stop-script-work/?p=69639

 

The bot itself i not using multiple threads (yet anyway) so with the one in the background there would be only two working. 

 

Any help would be great. 

 

Thanks

 

As an additional question what would be the best tutorials for multi-threading? Preferably one that assumes I do not have a clue. 

 

There is a plugin by Pash that enables you to use the "Main Button Click" and allows you to assign Run, Pause and Stop to a define and can be used for buttons :)

its not free but its definitely worth the money ;)

http://www.ubotstudio.com/forum/index.php?/topic/16097-sell-plugin-advanced-ubot-1/

  • Like 1
Link to post
Share on other sites

There is a plugin by Pash that enables you to use the "Main Button Click" and allows you to assign Run, Pause and Stop to a define and can be used for buttons :)

its not free but its definitely worth the money ;)

http://www.ubotstudio.com/forum/index.php?/topic/16097-sell-plugin-advanced-ubot-1/

 

Thanks.  

 

I already have the plugin though not sure how that function  would work in this situation. I tried setting it up a couple different ways and it did not work and threw off a bunch of errors. The video was not any help at all. I will post the screen shot with the errors over in the plugin thread and see if I can get some feedback on making it work. 

Link to post
Share on other sites

If you make the stop checker into a command it's not so bad then all you have to do is drag that custom command into your program in several places, a really basic example:

ui stat monitor("Count:", #count)
ui button("Stop") {
    set(#stop, "true", "Global")
}
set(#count, 0, "Global")
set(#stop, "false", "Global")
loop(100) {
    increment(#count)
    wait(.1)
    Stop Check()
}
define Stop Check {
    if($comparison(#stop, "=", "true")) {
        then {
            stop script
        }
        else {
        }
    }
}

Link to post
Share on other sites

That is similar to what I was already doing and would have done it for this bot as well but it seemed like there had to be a better way.

 

The main button click from Pash's plugin does the job perfectly with just a little tweaking to how I was setting it all up.   

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...