Jump to content
UBot Underground

How do you show the time decreasing in real time


Recommended Posts

Hey guys

 

I have a bot in which I want to incorporate the real-time decrement. What I mean is, when the process is in the waiting mode, then it should show on the UI panel that the next post will be made in xx:yy:zz time.

 

Yes, it can be done with UI Stat Monitor but how coz the lag time or the wait time is to be put by the user of the bot.

 

Can anyone point me in the correct direction how to achieve this!

 

Thanks

 

 

 

 

Link to post
Share on other sites

This shoud be able to help you :)  Make sure you put the "increment(#TriggerTow)" where ever your incremet counter is.

ui text box("Master Delay .Seconds", #MasterDelaySeconds)
ui text box("Run When Complete", #RunWhenCompletedCounter)
ui stat monitor("Master Delay Counter : ", #MasterDelayCounter)
set(#MasterDelayCounter, 0, "Global")
set(#TriggerTow, 0, "Global")
if($comparison(#RunWhenCompletedCounter, "=", #TriggerTow)) {
    then {
        set(#MasterDelayCounter, #MasterDelaySeconds, "Global")
        loop(#MasterDelaySeconds) {
            wait(1)
            decrement(#MasterDelayCounter)
        }
        set(#TriggerTow, 0, "Global")
    }
}
increment(#TriggerTow)
Link to post
Share on other sites

You are going to see inconsistent results in the end.  I would not recommend doing this.

 

To do it properly, there needs to be a way to place that routine in a place that gets slices of execution time without impairing the processing of the bot overall.

 

Just my opinion.

 

Buddy

Link to post
Share on other sites

UBS is an environment for rapidly creating applications and not really a programming environment like C or even Assembler where setting up a countdown like clock would be easier.

 

UBot has it's own abilities and tweaking some code to countdown "Like a Clock" is eye-candy for the user and that my friend "in my humble opinion" detracts from the bots processing.  Placing a "Wait" within a looping process will add up to slowing the overall processing down.

 

I use them sparingly and only when necessary.

 

Just my opinion.

 

Buddy

Link to post
Share on other sites

UBS is an environment for rapidly creating applications and not really a programming environment like C or even Assembler where setting up a countdown like clock would be easier.

 

UBot has it's own abilities and tweaking some code to countdown "Like a Clock" is eye-candy for the user and that my friend "in my humble opinion" detracts from the bots processing.  Placing a "Wait" within a looping process will add up to slowing the overall processing down.

 

I use them sparingly and only when necessary.

 

Just my opinion.

 

Buddy

 

 

So you mean something like this would work better?

 

clear list(%Seconds)
clear list(%Minutes)
ui text box("Wait Time: \{min:sec\}", #Set Timer)
ui text box("Wait After - Follows", #Run After How Many Actions)
ui stat monitor("Default Counter : {#zero}<font color=\"Red\">{#Minutes}{#Delimiter}{#Secondary Counter}{#Seconds}</font>", $nothing)
set(#Delimiter, $nothing, "Global")
set(#Minutes, $nothing, "Global")
set(#Seconds, $nothing, "Global")
set(#Secondary Counter, $nothing, "Global")
add list to list(%Seconds, $list from text(#Set Timer, ":"), "Delete", "Global")
add list to list(%Minutes, $list from text(#Set Timer, ":"), "Delete", "Global")
set(#Trigger Tow, 0, "Global")
comment("REMOVE TRIGGER THREE BELOW TO TEST AND PLACE BACK WHEN IMPLMENTING THE CODE")
set(#Trigger Tree, 0, "Global")
set(#zero, 0, "Global")
if($comparison(#Trigger Tree, "=", #Run After How Many Actions)) {
    comment("Maset Wait Timer")
    then {
        set(#zero, $nothing, "Global")
        set(#Delimiter, ":", "Global")
        set(#Minutes, $list item(%Minutes, 0), "Global")
        set(#Seconds, $list item(%Seconds, 1), "Global")
        set(#Secondary Counter, $nothing, "Global")
        loop while($comparison(#Trigger Tow, "=", 0)) {
            decrement(#Seconds)
            if($comparison(#Seconds, "=", 9)) {
                then {
                    set(#Secondary Counter, 0, "Global")
                }
            }
            if($comparison(#Seconds, "=", "-1")) {
                then {
                    set(#Seconds, 00, "Global")
                }
            }
            if($comparison($list total(%Minutes), "=", 1)) {
                then {
                    decrement(#Minutes)
                    set(#Delimiter, $nothing, "Global")
                    if($comparison(#Minutes, "=", 0)) {
                        then {
                            set(#Trigger Tow, 1, "Global")
                        }
                    }
                }
            }
            if($both($comparison(#Seconds, "=", 0), $comparison(#Minutes, "=", 0))) {
                then {
                    set(#Trigger Tow, 1, "Global")
                }
            }
            if($comparison(#Seconds, "=", 0)) {
                then {
                    decrement(#Minutes)
                    if($comparison(#Minutes, "=", "-1")) {
                        then {
                            set(#Minutes, 0, "Global")
                            set(#Seconds, 0, "Global")
                            set(#Secondary Counter, 0, "Global")
                            set(#Trigger Tow, 1, "Global")
                        }
                    }
                }
            }
            if($comparison(#Seconds, "=", 0)) {
                then {
                    set(#Seconds, 59, "Global")
                    set(#Secondary Counter, $nothing, "Global")
                }
            }
            wait(1)
        }
        set(#Trigger Tree, 0, "Global")
        set(#Trigger Tow, 0, "Global")
        set(#Delimiter, $nothing, "Global")
        set(#Minutes, $nothing, "Global")
        set(#Seconds, $nothing, "Global")
        set(#Secondary Counter, $nothing, "Global")
        set(#zero, 0, "Global")
    }
}
comment("PLACE THE INCREMENT CODE BLOW WHERE YOUR ACATION FROM THE BOT IS TO BE COMPLETED / FOLLOWING / LIKEING etc... ")
increment(#Trigger Tree)
on load("Bot Loaded") {
    set(#zero, 0, "Global")
}
Link to post
Share on other sites

 

So you mean something like this would work better?

I think the best way would be to use DateTime plugin and store starting time as UNIX timestamp...when you wan't to check how much time passed you just compare the new UNIX timestamp to old one. Notice that this eliminates the need for a loop (which would count the time for you), making your bot faster as UBotBuddy mention.

Link to post
Share on other sites

I think the best way would be to use DateTime plugin and store starting time as UNIX timestamp...when you wan't to check how much time passed you just compare the new UNIX timestamp to old one. Notice that this eliminates the need for a loop (which would count the time for you), making your bot faster as UBotBuddy mention.

 

Sounds good, I will cheak that out.

Link to post
Share on other sites

Yep....what he said again.

 

@UBotDev maybe we should go on tour!  lol

Yeah, hehe. Sorry for taking words from your mouth, I noticed that I did that on another topic as well. :)

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