Jump to content
UBot Underground

Is there a loop forever method ?


Recommended Posts

No need for comparisons. Just use $true , in the below case I just increase the value of #i so that you can see that it works. $true is always true so...

 

 

ui stat monitor("i = ", #i)
set(#i, 0, "Global")
loop while($true) {
    increment(#i)
}

 

 

More efficient code this way and no need to slow it down with a comparison (you save a couple of clock cycles :) ). On the other hand, this will always be true and if you for some reason want to do a clean exit at some point then go ahead with the $comparison example and set #var to something else but 0.

 

Voila!

  • Like 1
Link to post
Share on other sites
No need for comparisons. Just use $true , in the below case I just increase the value of #i so that you can see that it works. $true is always true so...

 

 

ui stat monitor("i = ", #i)

set(#i, 0, "Global")

loop while($true) {

    increment(#i)

}

 

 

More efficient code this way and no need to slow it down with a comparison (you save a couple of clock cycles :) ). On the other hand, this will always be true and if you for some reason want to do a clean exit at some point then go ahead with the $comparison example and set #var to something else but 0.

 

Voila!

 

 

I guess i don't understand the logic. I'm confused

 

 

Here is what i have done as testing so far

 

(i tried anonym $true idea but can't make it work either)

 

ui button("Stop") {
    set(#loopforever, 1, "Global")
}
set(#loopforever, 0, "Global")
loop while(#loopforever) {
    if($comparison(1, "=", 1)) {
        then {
        }
        else {
            navigate("http://www.imeetzu.com/", "Wait")
            wait(5)
        }
    }
}
Link to post
Share on other sites

I think i got it

 

ui button("Stop") {
    set(#loopforever, 1, "Global")
}
set(#loopforever, 0, "Global")
loop while($comparison(#loopforever, "=", 0)) {
    navigate("http://www.imeetzu.com/", "Wait")
    wait(3)
}

 

 

Guys, how would i use Anonym idea to make the script do less things with a working stop button ?

 

Thanks

 

EDITED:

 

i THINK I GOT IT

 

ui button("Stop") {
    set(#loopforever, 1, "Global")
}
set(#loopforever, 0, "Global")
loop while($true) {
    if($comparison(#loopforever, "=", 1)) {
        then {
            stop script
        }
        else {
        }
    }
    navigate("http://www.imeetzu.com/", "Wait")
    wait(3)
}

but something odd is happening, when i try to go to the code view, it says to finish all nodes ??? When they are finished. In fact, i had to save the project, close down UB and reload it with the project so i could copy the code to paste it in here ?

 

Anyways...

Link to post
Share on other sites

either

for(;; ){
//put the code you want to loop forever here.
}


or
    

int temp = 0;
while (temp !=1){
/*
put the code you want to loop forever here.
Make sure you never put temp = 1 in the code you put.
*/
}

Edited by nancy30
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...