Jump to content
UBot Underground

On Idle Command?


Recommended Posts

Hello.

 

I'm looking for a way to run certain commands when my bot is idle. 

 

All my code is within several define commands. And all functions are triggered by UI Buttons.

I have a progress bar and a status text window.

 

The different activities change the progress bar and the status window.

 

Now I would like to reset the progress bar and the status window after a while. 

But I don't want to do it at the end of my define commands. I want to show the last message for another 3-5 seconds, but then reset it to the default.

 

But without delaying the bot. So pause and changing it at the end of the define is not what I'm looking for.

 

If someone has a smart way to do that, I'm very interested to hear about it.

 

Thanks in advance for your help

Dan

Link to post
Share on other sites

so to get this right, if the message showed for the 3-5 seconds, and then it "waited a while" and the whole thing started again, that would be ok?

 

I think I have an idea:

 

define resetstatus {

    thread {

        wait(5)

        if($comparison(#runthread"=", 1)) {

            then {

                set(#status"<font color=\"#FFFFFF\">Bereit...</font>""Global")

                set(#progressbar, 0, "Global")

            }

            else {

            }

        }

    }

}

 

And at the beginning of every define command I do:

set(#runthread"0""Global")

 

and at the end

set(#runthread"1""Global")

resetstatus()

 

 

That should do the job.. Testing it now.

 

Dan

Edited by dan
Link to post
Share on other sites

Try this out. Click on a command button and it will run after it says "Finished!" it will wait 4 seconds then clear the progress bar,  however, if you click on one of the command buttons in that 4 seconds it will run that command and not reset the progress bar (except back to 1 which it does in the command but it wont reset part way through that command) - I hope that makes sense.

I think that's what you're going for?

ui button("Command 1") {
    set(#progress_ready, "false", "Global")
    set(#progress, 1, "Global")
    loop(99) {
        wait(0.05)
        increment(#progress)
    }
    wait(1)
    alert("Finished!")
    set(#progress_ready, "true", "Global")
    change progress bar()
}
ui button("Command 2") {
    set(#progress_ready, "false", "Global")
    set(#progress, 1, "Global")
    loop(99) {
        wait(0.05)
        increment(#progress)
    }
    wait(1)
    alert("Finished!")
    set(#progress_ready, "true", "Global")
    change progress bar()
}
ui stat monitor("Progress:", #progress)
define change progress bar {
    loop(4) {
        wait(1)
        if($comparison(#progress_ready, "=", "true")) {
            then {
            }
            else {
                stop script
            }
        }
    }
    set(#progress, 0, "Global")
}

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