Results 1 to 8 of 8

Thread: Function Error.

  1. #1
    Join Date
    Aug 2007
    Posts
    53
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Function Error.

    Please take time to read this post. I'm sure that you can be more of a help if you read it all.

    I'm fairly new to Scar. I actually started with it 3 days ago.
    I created a function for the sandwich lady.

    SCAR Code:
    function sandwichlady(x,y:Integer): Boolean;
    begin
      if (findcolortolerance(x,y,15066600,0,0,516,338,7))
        and
         (findcolortolerance(x,y,8226746,0,0,516,338,7)) then
        begin
        Result:=True;
        getMousePos(x,y);
        end;
          end;
    The problem isn't with findcolortolerance, in fact this part work perfectly.
    It seem that
    SCAR Code:
    getMousePos(x,y);
    isn't working. It should return the value of x and y in findcolortolerance, but it doesn't.

    Example:
    SCAR Code:
    program lol;

    var
      x,y: Integer;

    begin
      if (sandwichlady(x,y)) then
        moveMouseSmooth(x,y);
        wait(1000);
    end.
    The mouse should move to the lady, but instead, it only moves to coordinates: 0,0.

    Now you have my problem.

  2. #2
    Join Date
    Feb 2007
    Location
    SparklesProd.com
    Posts
    2,406
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Test this script (uses srl, does what you want. lol).

    Doesnt move the mouse to 0,0
    SCAR Code:
    program lol;

    {.include SRL\SRL.scar}

    var
      x,y: Integer;

    function sandwichlady: Boolean;
    begin
      if (findcolortolerance(x,y,15461094,0,0,516,338,7))
      and
      (findcolortolerance(x,y,15461094,0,0,516,338,7)) then
       begin
        Result:=True;
       end
        else
         begin
          Result := False;
          Writeln('Color not found');
         end;
    end;

    begin
    SetupSRL;
      if (sandwichlady) then
        MMouse(x,y,0,0);
        wait(1000);
    end.

  3. #3
    Join Date
    Aug 2007
    Posts
    53
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey thanks =)

  4. #4
    Join Date
    Feb 2007
    Location
    SparklesProd.com
    Posts
    2,406
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    No problem. Glad to help. Post if you need any more help.

  5. #5
    Join Date
    Aug 2007
    Posts
    53
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Actually is it possible for an alternative. because I really want the coordinates to go in
    Code:
    sandwichlady(x,y);

  6. #6
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Ah I had this same problem a month ago. It's a simple fix. Just change the arguments to
    SCAR Code:
    function sandwichlady(var x,y:Integer): Boolean;

  7. #7
    Join Date
    Aug 2007
    Posts
    282
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by bullzeye95 View Post
    Ah I had this same problem a month ago. It's a simple fix. Just change the arguments to
    SCAR Code:
    function sandwichlady(var x,y:Integer): Boolean;
    and take out getmousepos

    becasue color finding does NOT move the mouse to the color, it saves the coords as the vars you put in.. normaly x,y.. so if you getmousepos(x,y) it overrides where the color was, and gets where the mouse was at the begining.

    does that make sence? kinda hard to explain

  8. #8
    Join Date
    Oct 2006
    Posts
    2,297
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Wilio View Post
    Actually is it possible for an alternative. because I really want the coordinates to go in
    Code:
    sandwichlady(x,y);
    like Bullszeye said, you have to put var:
    function Sandwichlady(var x, y: integer): boolean;

    then before you take the mouse coordinates, move your mouse to the place were the sandwich lady was found, so you have to use the MMouse procedure, after that you can pick the coordinates
    [QUOTE=Santa_Clause;277761]I love you too TSN :p[/QUOTE]
    [CENTER][URL="http://www.stats.srl-forums.com/sigs"][IMG]http://www.stats.srl-forums.com/sigs/1324.png[/IMG][/URL][/CENTER]

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. function causing runtime error
    By cocodog13 in forum OSR Help
    Replies: 7
    Last Post: 03-30-2008, 11:01 AM
  2. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  3. Replies: 2
    Last Post: 05-20-2007, 10:32 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
  •