Results 1 to 19 of 19

Thread: Repeat/Until Question.

  1. #1
    Join Date
    Jan 2008
    Location
    Stanford, CA
    Posts
    329
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Repeat/Until Question.

    Ok. say for example you had this

    SCAR Code:
    begin
      repeat
         FindColor(blah,blah);
      until(FindColor(Blah,blah);
    end;

    could i simply do this instead?

    SCAR Code:
    begin
      repeat
        Wait(10);
      until(FindColor(Blah,Blah));
    end;

    because in my script i wanna apply this (in essense)

    SCAR Code:
    begin
      repeat
         Mouse(x,y,1,1,false);
         Wait(1000);
      until(chooseoption('x'));
    end;

    but i dont know if it would work. although the only other way i thought of was to do this

    SCAR Code:
    begin
      repeat
        Mouse(x,y,1,1,false);
        Wait(1000);
        ChooseOption('x');
      until(chooseoption('x'));
    end;


    could someone clarify this for me?

  2. #2
    Join Date
    Sep 2007
    Location
    Pennsylvania
    Posts
    3,396
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    begin
      repeat
         Mouse(x,y,1,1,false);
         Wait(1000);
      until(chooseoption('x'));
    end;

    Will work

  3. #3
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    begin
      repeat
         Mouse(x,y,1,1,false);
         Wait(1000);
      until(chooseoption('x'));
    end;

    should work, repeat..until does the stuff until the until returns true..so actually that last one wouldn't work at all, because the chooseoption wouldn't work the second time, since its almost gone
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

  4. #4
    Join Date
    Jan 2008
    Location
    Stanford, CA
    Posts
    329
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    alright thanks guys, that cleared up a lotta things for me =)

    but say for example i am doing this

    SCAR Code:
    begin
      repeat
         Mouse(x,y,1,1,false);
         Wait(1000);
      until(chooseoption('x'));
       if chooseoption('x')then
     //blah blah
    end;

    would this work? would the if/then 'take into consideration' that the chooseoption was done?

  5. #5
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    You should be using the one drizzt posted, although failsafes should be included just in case it doesn't work.
    :-)

  6. #6
    Join Date
    Jan 2008
    Location
    Stanford, CA
    Posts
    329
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    i know but what i am asking is if the failsafe i added would work to trigger the 'if/then' function.
    like if

    SCAR Code:
    //first part of repeat
    until(chooseoption('make all'));
    if chooseoption('make all'); //Would this go by  wat the until did? or would it try its own
    //separate function?

  7. #7
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    begin
      repeat
         Mouse(x, y, 1, 1, False);
         Wait(1000);
         if ChooseOption('x') then
         begin  
           Clicked := True;
           Break;
         end;
      until(ChooseOption('x'));
      if Clicked then
    end;

    That would work.
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  8. #8
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    See above, since he edited his post now.
    :-)

  9. #9
    Join Date
    Jan 2008
    Location
    Stanford, CA
    Posts
    329
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    there we go. thanks guys =). btw repped both of ya guys

  10. #10
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Method View Post
    That wouldn't work either. You'd need to do:

    SCAR Code:
    begin
      repeat
        Mouse(x, y, 1, 1, False);
        Wait(1000);
        if ChooseOption('x') then
          Clicked := True;
        if Clicked then
          Break;
      until(ChooseOption('x'));
    end;

    or:

    SCAR Code:
    begin
      repeat
        Mouse(x, y, 1, 1, False);
        Wait(1000);
        if ChooseOption('x') then
          Clicked := True;
      until(Clicked);
    end;

    With that, you'd just need to make sure you made a variable named Clicked that's a boolean. Plus, if you called that function more than once, you'd need to reset clicked to make sure you don't get faulty results.
    Did you even read what I did?
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  11. #11
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    You edited your post to include scar tags and updated your little snippet after I made my post. Before I posted, you did not have what you currently have. Plus, you have if Clicked then at the end of the snippet for seemingly no reason at all. I apologize for posting an alternate way, but what you had before didn't work.
    :-)

  12. #12
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Method View Post
    You edited your post to include scar tags and updated your little snippet after I made my post. Before I posted, you did not have what you currently have. Plus, you have if Clicked then at the end of the snippet for seemingly no reason at all. I apologize for posting an alternate way, but what you had before didn't work.
    Oh, that's what you meant, my bad You posted like 4 minutes after me. I have the if Clicked then because from what I understand, he wants to carry out one thing if the result is true, and carry out another if the result is false.

    No need for apologies I apologise
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  13. #13
    Join Date
    Apr 2007
    Location
    Michigan -.-
    Posts
    1,357
    Mentioned
    2 Post(s)
    Quoted
    4 Post(s)

    Default

    Quote Originally Posted by Santa_Clause View Post
    SCAR Code:
    begin
      repeat
         Mouse(x, y, 1, 1, False);
         Wait(1000);
         if ChooseOption('x') then
         begin  
           Clicked := True;
           Break;
         end;
      until(ChooseOption('x'));
      if Clicked then
    end;

    That would work.
    But wouldnt that just call the ChooseOption an extra unnecessary time with it at the until?

    Maybe put a timing failsafe and try a while do?

    SCAR Code:
    Clicked := False;
    MarkTime(Time);
    while Clicked = False do
    begin
      if(TimeFromMark(Time) > 15000)then
      begin
        NextPlayer(False);
        Exit;
      end;
      Mouse(x, y, 1, 1, False);
      Wait(1000);
      if ChooseOption('x') then
        Clicked := True;
    end;

    Something like that could work as well, without the extra call of ChooseOption.
    METAL HEAD FOR LIFE!!!

  14. #14
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Or do it like this:
    SCAR Code:
    If not ChooseOption('x') then
      If Not ClickOption('x') then
       Begin
        If Not ChooseOption2('x'); then { Not sure of this one ;S}
          If Not FindBitmap(Xbmp, x, y) then
           Begin
            Repeat
              i:=i+1;
              Wait(800+Random(700))
            Until(FindBitmap(xbmp, x, y)) or (i > 10) or ChooseOption('x')= True;
        end;
    end;
    ^Maybe try that, Or read my tutorial on failsafes

    Hope I Helped

  15. #15
    Join Date
    Jan 2008
    Location
    Stanford, CA
    Posts
    329
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    but hey gerauchert would that keep repeating until clicked=true? or timefrommark>15000? because i usually dont really apply while/do's into my script

    (to Nauman) haha ill be sure to read up on ur failsafe TUT.

  16. #16
    Join Date
    Apr 2007
    Location
    Michigan -.-
    Posts
    1,357
    Mentioned
    2 Post(s)
    Quoted
    4 Post(s)

    Default

    Yes. A while do statement is does pretty much the same thing as a repeat only that it repeats only while a certain condition is met. So it will repeat that until clicked is true. Once it is true it will break out of the loop because the condition is met.

    With a repeat you are repeating something until a certain condition is met... so you would be calling ChooseOption twice in the repeat and once in the while do.

    I hope that makes sense

    EDIT: I re-read your post, and I kinda messed up answering you. It will repeat that until either of those conditions are met. The timer is a failsafe so that it wont repeat forever, so after 15 seconds or whatever time you want, it will assume that it failed and will switch to the next player. If the chooseoption is successful, then it will break out of the loop. So it depends on what happens lol.
    METAL HEAD FOR LIFE!!!

  17. #17
    Join Date
    Jan 2008
    Location
    Stanford, CA
    Posts
    329
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    haha alright seems pretty useful =). i think it will work just as well as repeat/until. thanks guhys

  18. #18
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by gerauchert View Post
    But wouldnt that just call the ChooseOption an extra unnecessary time with it at the until?

    Maybe put a timing failsafe and try a while do?

    SCAR Code:
    Clicked := False;
    MarkTime(Time);
    while Clicked = False do
    begin
      if(TimeFromMark(Time) > 15000)then
      begin
        NextPlayer(False);
        Exit;
      end;
      Mouse(x, y, 1, 1, False);
      Wait(1000);
      if ChooseOption('x') then
        Clicked := True;
    end;

    Something like that could work as well, without the extra call of ChooseOption.
    It's not really an 'extra' call, since it would break from the loop if it clicks on the ChooseOption. Only problem with having it there is that Clicked won't be set to true.
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  19. #19
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Why Put Fail safes for this stuff... Man that would get kind of annoying... -.o


    just do

    SCAR Code:
    Mouse(x, y, 1, 1, False);
    ChooseOption('x');

    i don't think i have had my script fail at that lol...

    if you really have to then just do...

    SCAR Code:
    while (not(Bool)) do
     begin
       Mouse(x, y, 1, 1, False);
       Wait(1000);
       Bool := ChooseOption('x');
     end;

     if (bool) then blah blah

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Repeat?
    By FortAsh in forum OSR Help
    Replies: 9
    Last Post: 01-13-2009, 04:18 PM
  2. How do I get this to repeat until?
    By Claymore in forum OSR Help
    Replies: 2
    Last Post: 07-07-2008, 04:02 PM
  3. After each repeat...
    By Bourdou! in forum OSR Help
    Replies: 7
    Last Post: 08-15-2007, 01:16 AM
  4. repeat help
    By trojan in forum OSR Help
    Replies: 2
    Last Post: 06-15-2007, 03:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •