Results 1 to 6 of 6

Thread: while...do

  1. #1
    Join Date
    Jul 2007
    Posts
    238
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default while...do

    hiya folks its been a long long time ive posted something on this forums :$
    but ones again i need your help
    i made a small script for a game(nostale)mini game
    something like this

    SCAR Code:
    program New;
    var

    x,y: Integer;


     begin
     repeat
                 if (FindColorTolerance(x,y,5105865,606,570,640,575,15))or (FindColorTolerance(x,y,45849,606,570,640,575,15))
                 or (FindColorTolerance(x,y,11301376,606,570,640,575,15))then
                 SendArrow(1)
                 
                              if (FindColorTolerance(x,y,5105865,414,567,420,570,15))or (FindColorTolerance(x,y,11301376,414,567,420,570,15))
                              or (FindColorTolerance(x,y,38026,414,567,420,570,15))then
                 SendArrow(3)
                 else
                 begin
                  Wait(120+random(20));
                  sendarrow(0)
                  end
                 until false
    end.

    easy...it works but i wanted to make it better

    something like this

    SCAR Code:
    program New;
    var

    x,y: Integer;
    begin
       while (wait(1000));
              SendArrow(3)DO
         begin
                  (FindColorTolerance(x,y,5105865,606,570,640,575,15))or (FindColorTolerance(x,y,45849,606,570,640,575,15))
                 or (FindColorTolerance(x,y,11301376,606,570,640,575,15))then
                 SendArrow(1)
                 
                              if (FindColorTolerance(x,y,5105865,414,567,420,570,15))or (FindColorTolerance(x,y,11301376,414,567,420,570,15))
                              or (FindColorTolerance(x,y,38026,414,567,420,570,15))then
                 SendArrow(3)
        end;

    end.

    but then im getting this error
    PHP Code:
    Line 8: [Error] (8:19): 'DO' expected in script 
    can someone plz help me ones again ?
    ....

  2. #2
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    you put a semi-colon in, so it ends the command prematurely - add the wait(1000) into the main loop as well as it's a procedure and doesn't return a boolean so can't be used. All 'while (blah=blah2) do' is a 'repeat until (not(blah=blah2))' so you have to make sure you only use functions in it as you need something to compare (or a variable).
    SCAR Code:
    program New;
    var
    x,y: Integer;

    begin
      while (SendArrow(3){change to anything else that returns a boolean or can compare (like x=1)}) do
      begin
        wait(1000);
        if(FindColorTolerance(x,y,5105865,606,570,640,575,15)) or
          (FindColorTolerance(x,y,45849,606,570,640,575,15)) or
          (FindColorTolerance(x,y,11301376,606,570,640,575,15)) then
          SendArrow(1);            
        if(FindColorTolerance(x,y,5105865,414,567,420,570,15)) or
          (FindColorTolerance(x,y,11301376,414,567,420,570,15)) or
          (FindColorTolerance(x,y,38026,414,567,420,570,15)) then
          SendArrow(3);
      end;
    end.
    Also fixed general standards (just makes it easier to read).
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  3. #3
    Join Date
    Jul 2007
    Posts
    238
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i never liked standardstheywhere always a mess
    but have u tried to compile ur script ?
    cuz it doesnt works
    ....

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    2,984
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    When you convert your first program in a while loop you'll get this :

    SCAR Code:
    program New;

    var
      x,y: Integer;

    begin
      while true do
      begin
        if(FindColorTolerance(x,y,5105865,606,570,640,575,15))or(FindColorTolerance(x,y,45849,606,570,640,575,15))or(FindColorTolerance(x,y,11301376,606,570,640,575,15))then
          SendArrow(1)

         if(FindColorTolerance(x,y,5105865,414,567,420,570,15))or(FindColorTolerance(x,y,11301376,414,567,420,570,15))or(FindColorTolerance(x,y,38026,414,567,420,570,15))then
           SendArrow(3)
         else begin
           Wait(120+random(20));
           sendarrow(0)
         end
      end;
    end.

    Also added some standards there.. in a repeat, you repeat something until the statement in until turns true. You did until(False); so that never turns true so it loops endlessly. A while loop works the other way around. While something is true it is supposed to do something. If it turns false it will break out of it. Since you wanted an endless loop, or at least im assuming you do, you get while(True)do.
    Administrator's Warning:


  5. #5
    Join Date
    Jul 2007
    Posts
    238
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yes thats something i wanted but i really wanted to do this like this..repeat this until i stop the script

    SCAR Code:
    while        Wait(120+random(20))       sendarrow(0) DO
      begin
        if(FindColorTolerance(x,y,5105865,606,570,640,575,15))or(FindColorTolerance(x,y,45849,606,570,640,575,15))or(FindColorTolerance(x,y,11301376,606,570,640,575,15))then
          SendArrow(1)

         if(FindColorTolerance(x,y,5105865,414,567,420,570,15))or(FindColorTolerance(x,y,11301376,414,567,420,570,15))or(FindColorTolerance(x,y,38026,414,567,420,570,15))then
           SendArrow(3)
    ....

  6. #6
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Sorry it didn't compile - I always type it out on the forum rather than in scar, I really wish you could test for compile on the forums ><.
    It didn't compile because SendArrow's doesn't return a boolean, so that's why. Changed it to do while true so it repeats forever (as sumulion said) and moved the SendArrow into the loop (feel free to remove the standards ). I think this is what you meant now (just repeating the wait and sendarrow(3) until you press F6 (change it to whatever).
    SCAR Code:
    program New;
    var
    x,y: Integer;

    begin
      while (not(IsFKeyDown(6))) do
      begin
        wait(1000);
        SendArrow(3)
      end; // Move this after the FindColorTolerances if this isn't what you wanted
      if(FindColorTolerance(x,y,5105865,606,570,640,575,15)) or
        (FindColorTolerance(x,y,45849,606,570,640,575,15)) or
        (FindColorTolerance(x,y,11301376,606,570,640,575,15)) then
        SendArrow(1);
      if(FindColorTolerance(x,y,5105865,414,567,420,570,15)) or
        (FindColorTolerance(x,y,11301376,414,567,420,570,15)) or
        (FindColorTolerance(x,y,38026,414,567,420,570,15)) then
        SendArrow(3);
    end.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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