Results 1 to 14 of 14

Thread: Basic Script help

  1. #1
    Join Date
    May 2008
    Location
    Utah
    Posts
    117
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Talking Basic Script help

    Hey!

    I have read the beginner guide a couple times now and I have tried to put my knowledge to use, I don't believe I am doing it right though.

    Here is the script I have:

    SCAR Code:
    Program colorfinder;

    {to find yellow balloon text button on pdf program
     Begin at loc 22,556, Use Spiral colorfind until finding color for button.}

    function FindColor1: Integer;

      begin
         FindColorCircle: 28460473;
      end;      

    Procedure WriteLn1;
      begin //once found color write in found color
       if FindColor1 := True
       Then WriteLn('I have found what you were looking for :)')
       TerminateScript;
      end;

    begin
       FindColor1
       WriteLn1
    end.

    It is supposed to be very simple, find the yellow color balloon button on a open pdf file. (I am not using bitmaps for now.) I want it to start at a certain point and go out. After it finds the color it types in the Debug box the message above.



    I have tried compiling this in Luna, as it has a bit more friendly tips and easier to read begin and end functions, as they are linked together. I know it does not work as there are some things missing, but I am not sure what to put or how?

    Any help would be great, I have said in other posts that I have been wanting to learn as much as I can. So by all means, if it is brutal, bring it. :P
    Last edited by Rizowski; 05-22-2010 at 08:03 PM. Reason: image

  2. #2
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    SCAR Code:
    function FindTheYellowBalloon: Boolean;
    var
      Arr: TPointArray;
    begin
      FindColorsSpiralTolerance(x, y, Arr, ColorHere, x1, y1, x2, y2, ToleranceHere);
      if Length(Arr) > 1 then
      begin
        Result := True;
        Writeln('mssage here');
      end;
    end;
    'x' and 'y' specify where you want to start searching from.
    'Arr' is just the array that the function will store the points where it finds the color.
    'x1' and 'y1' represent the top right corner of the box you want to search in.
    'x2' and 'y2' represent the bottom right corner of the box you wish to search.

    When you open up scar, press f1 and it will bring up asort of "guide" on the functions and very briefly explain how to use them.
    Last edited by NCDS; 05-22-2010 at 08:16 PM.

  3. #3
    Join Date
    May 2008
    Location
    Utah
    Posts
    117
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    So the Arr does not need to be filled in with anything or is does it need to be modified?

  4. #4
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Nope you would leave 'Arr' just as it is.

  5. #5
    Join Date
    May 2008
    Location
    Utah
    Posts
    117
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok so I put in the required info. Executed the script and only received this:

    Successfully compiled (70 ms)
    Successfully executed

    What would cause it not to put in the write in command?

  6. #6
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    if it didn't find at least two occurrence's of the color you searched for.

    Change:
    SCAR Code:
    if Length(Arr) > 1 then
      begin
        Result := True;
        Writeln('mssage here');
      end;
    to:
    SCAR Code:
    if Length(Arr) > 1 then
      begin
        Result := True;
        Writeln('mssage here');
      end
      else
        Writeln('failed to find color');

  7. #7
    Join Date
    May 2008
    Location
    Utah
    Posts
    117
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Cool! haha Thanks

  8. #8
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    You could also make it return a TPoint so you can call it then click =)

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  9. #9
    Join Date
    May 2008
    Location
    Utah
    Posts
    117
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Dgby714 View Post
    You could also make it return a TPoint so you can call it then click =)
    Tpoint? Please Explain?

  10. #10
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    'x1' and 'y1' represent the top right corner of the box you want to search in.
    You mean top left corner?

  11. #11
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by moae3 View Post
    Tpoint? Please Explain?
    So Basically a TPoint is

    SCAR Code:
    type
      TPoint = record
        x: integer;
        y: integer;
      end;

    So you can store x, y coordinates, Like where you want to click =)

    SCAR Code:
    function FindTheYellowBalloon: TPoint;  //<-- Result is now a TPoint
    var
      Arr: TPointArray; //Arr is a array of TPoint
    begin
      Result := Point(-1, -1);  //We will make Result = -1, -1 (x, y) Just incase You dont find the colors

      FindColorsSpiralTolerance(x, y, Arr, ColorHere, x1, y1, x2, y2, ToleranceHere);

      if Length(Arr) > 1 then
      begin
        //Now here you can loop thru Arr and find the best match but were just gonna use Arr[0]
        Result := Arr[0]; //Result := the first TPoint in Arr
        Writeln('mssage here');
      end;
    end;

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  12. #12
    Join Date
    May 2008
    Location
    Utah
    Posts
    117
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by IceFire908 View Post
    You mean top left corner?
    It still worked?



    Quote Originally Posted by Dgby714 View Post
    So Basically a TPoint is

    SCAR Code:
    type
      TPoint = record
        x: integer;
        y: integer;
      end;

    So you can store x, y coordinates, Like where you want to click =)

    SCAR Code:
    function FindTheYellowBalloon: TPoint;  //<-- Result is now a TPoint
    var
      Arr: TPointArray; //Arr is a array of TPoint
    begin
      Result := Point(-1, -1);  //We will make Result = -1, -1 (x, y) Just incase You dont find the colors

      FindColorsSpiralTolerance(x, y, Arr, ColorHere, x1, y1, x2, y2, ToleranceHere);

      if Length(Arr) > 1 then
      begin
        //Now here you can loop thru Arr and find the best match but were just gonna use Arr[0]
        Result := Arr[0]; //Result := the first TPoint in Arr
        Writeln('mssage here');
      end;
    end;

    So I tried to run the script as is after inserting needed info. It came up with:

    Line 1: [Error] (1:1): Unexpected end of file in script

    I looked at the way it was written previously and noticed it has:

    SCAR Code:
    function FindTheYellowBalloon: Boolean;

    So I replaced: TPoint with TPointArray? It seemed to work other than it stated this error
    Line 6: [Error] (6:23): Type mismatch in script
    ? I tried to put in a point and some other things to see if i could correct it. But haha idk what is wrong?

  13. #13
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Weird

    This compiles for me perfecty fine >.<
    SCAR Code:
    program new;

    const
      ColorHere = 0;
      ToleranceHere = 0;
      x1 = 0;
      x2 = 0;
      y1 = 0;
      y2 = 0;

    function FindTheYellowBalloon: TPoint;  //<-- Result is now a TPoint
    var
      x, y: integer;
      Arr: TPointArray; //Arr is a array of TPoint
    begin
      Result := Point(-1, -1);  //We will make Result = -1, -1 (x, y) Just incase You dont find the colors

      FindColorsSpiralTolerance(x, y, Arr, ColorHere, x1, y1, x2, y2, ToleranceHere);

      if Length(Arr) > 1 then
      begin
        //Now here you can loop thru Arr and find the best match but were just gonna use Arr[0]
        Result := Arr[0]; //Result := the first TPoint in Arr
        Writeln('mssage here');
      end;
    end;

    begin
    end.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  14. #14
    Join Date
    May 2008
    Location
    Canada
    Posts
    665
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Still keeping it simple and to your original post. I learn by comparing code, maybe you do as well . Simple, and straight forward. Included two code. Your way, and a shorter way.

    SCAR Code:
    // Your Code modified
    Program colorfinder;

    {to find yellow balloon text button on pdf program
     Begin at loc 22,556, Use Spiral colorfind until finding color for button.}

     
    var x,y:integer;
     
     
    function FindColor1: Boolean; // Boolean will return either true or false.

      begin                             // the dimensions to look in (0,0 is top left)
         if(FindColor(x,y,28460473,     0,0,999,999))then
         begin
           result := true;    // we use := to assign values.
         end else // otherwise... must contain begin statement. Also represents end of that begin
         begin
           result := false;
         end;
      end;

    Procedure WriteLn1;
      begin //once found color write in found color
       if (FindColor1 = True) then  // we don't use := here because it is comparing two variables.
       begin
         WriteLn('I have found what you were looking for :)')
         TerminateScript;
       end else
       begin
         writeln('Nope, not found');
       end;
      end;

    begin
       FindColor1
       WriteLn1
    end.

    SCAR Code:
    //How I would have done it
    Program colorfinder;

    var x,y:integer;

    begin
      If(FindColor(x,y,28460473,0,0,999,999))then
      begin
        Writeln('I have found what you were looking for :)');
      end else
      begin
        Writeln('Nope, not found!');
      end;
    end.

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
  •