Results 1 to 6 of 6

Thread: Colour Finding

  1. #1
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default Colour Finding




    Contents

    C1 - Introduction
    C2 - FindColor

    C3 - FindColorTolerance
    C4 - FindColorSpiral
    C5 - FindColorSpiralTolerance
    C6 - The FindColors Functions
    C7 - Finding Colours In Runescape
    C8 - Closing Notes

    To skip to the part of the tutorial you wish to read, press F3, and then type in the C number which is found above.


    C1 - Introduction

    If you have just learned to basics of SCAR scripting, and now want to move onto learning how to create scripts for Runescape, then you are in the right place. In this tutorial I am going to show you how to find colours on your screen using SCAR. I will be showing you how to use functions which are implemented into SCAR. Colour finding may sound simple, but it plays an important role in SCAR, as SCAR is a colour based program. On with the tutorial...


    C2 - FindColor

    Code:
    function FindColor(var X, Y : Integer; Xs, Ys, Xe, Ye : Integer) : Boolean;


    You may have already heard of this, as this is as simple as colour finding gets. However, this would be perfect for, for example, finding the green colour on my Start Button, as it never changes:


    To get the colour you click on the colour picker:


    You will now see a box, and a crosshair appear. It will look something like this:


    - Mouse: 0, 0 is the X, Y position of the mouse.
    - Color: 0 is the color where the crosshair is

    To get the colour, I would just put the crosshair over it, and click.

    Now you will see something like this:
    Code:
    Color Picked: 8910240 at (25, 850)
    Appear in the debug box. If you don't know what the debug box is, then:


    Now...
    - Color Picked: 8910240 is the color where the crosshair was when you clicked.
    - at (25, 850) is the X, Y coordinates where the colour was picked.

    Now we know the colour, let's do something with it. It's all explained inside the script:

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}

    var
      X, Y : Integer; //Used for finding colours...and pretty much everything else

    procedure MouseToColour;
    begin
      Mouse(X, Y, 0, 0, True);{ This moves the mouse to where the colour was found, and left clicks
    If this was Runescape, then you would do:

    MMouse(X, Y, 5, 5); This moves the mouse to where the colour was found, with 5 X, Y randomness
    if WaitUpText('oins', '750) then This waits a max of 750MS for uptext "oins" to appear. If it does then
    begin If there is more than one function called after "then", you need a begin/end;
    GetMousePos(X, Y); Gets the position of the mouse and saves it to X, Y
    Mouse(X, Y, 0, 0, True); Lefts clicks X, Y with no randomness...Why? We already had 5 in MMouse
    end; end; for the begin 3 lines up}

    end;

    procedure TryFindColour;
    begin
      if FindColor(X, Y, 8910240, 0, 0, 180, 863) then //If it finds colour(8910240) at any point in
        MouseToColour; //0, 0, 180, 863 it will call the MouseToColour procedure
    end;

    begin
      SetupSRL; //Sets up the almighty SRL for use
      TryFindColour; //Calls TryFindColour
    end.

    FindColor is fine for finding colours on games for which the colours don't change, but on Runescape, they do. For this, we need tolerance!


    C3 - FindColorTolerance

    Code:
    function FindColorTolerance(var X, Y : Integer; Xs, Ys, Xe, Ye, Tol : Integer) : Boolean;


    Quote Originally Posted by Dictionary.net View Post
    5: Tolerance is a permissible difference; allowing some freedom to move within limits - Also: allowance, leeway, margin
    This is like FindColor, except we can use tolerance. This is declared under the extra parameter of Tol. The higher the tolerance, the more tolerant the function will be - duh! Let's use FindColorTolerance to find the colour of logs in our inventory, on Runescape. There are other, better ways to find items in the inventory, but this is just an example.

    So, here are our logs:


    As shown above, find the colour using the colour finder. Now we have the number in the debug box:

    Code:
    3167854
    Let's use FindColorTolerance to find it.

    A good tolerance for Runescape is between 15 and 30. I normally use 20 myself, and it works fine.

    SCAR Code:
    program FCT;
    {.include SRL/SRL.scar}

    var
      X, Y : Integer; //X, Y integer for storing coordinated

    function DropLogs : Boolean; //Declare DropLogs as a boolean
    begin
      if FindLogColour then //Calls FindLogColour - no need to call in main loop
      begin //If FindLogColour, then it will begin
        MMouse(X, Y, 5, 5); //Moves mouse to where colour was found with 5 X, Y randomness
        if WaitUpText('ogs', 600) then //Waits max 600MS for uptext "ogs" to appear
        begin //If it does, then it will begin
          GetMousePos(X, Y); //Stores where mouse is to X, Y
          Mouse(X, Y, 0, 0 False); //Right clicks no randomness - already 5 randomness in MMouse
          Result:= WaitOption('rop', 600); //Wait max 600MS for option "rop" to appear. If it does, then Result = True
        end;
      end;
    end;

    function FindLogColour : Boolean;
    begin
      Result:= FindColorTolerance(X, Y, 3167854, MIX1, MIY1, MIX2, MIY2, 20); //If it find the colour in the inventory with 15 randomness, then Result = True
    end;

    begin
      SetupSRL; //Sets up SRL
      DropLogs; //Calls DropLogs. No need to call FindLogColour as it is called in DropLogs.
    end.




    Nice...But if you're using this on the main screen, then this might find the tree (as an example) farthest away from you. This is where you need the functions to spiral!


    C4 - FindColorSpiral




    C5 - FindColorSpiral Tolerance




    C6 - The FindColors Functions




    C7 - Finding Colours In Runescape




    C8 - Closing Notes


    EDIT:Thanks to the mod who changed the name.

    Last edited by Rich; 09-02-2009 at 03:22 AM.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  2. #2
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Reserved.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  3. #3
    Join Date
    Mar 2006
    Location
    Behind you
    Posts
    3,193
    Mentioned
    61 Post(s)
    Quoted
    63 Post(s)

    Default

    You got me interested. you have explain it in a unique way. not really what i was looking for help with but still a good start to tut. Hope you'll Finish Writing it up soon. i'd be interested in rereading it.

  4. #4
    Join Date
    Feb 2007
    Posts
    849
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Gravedig (sorta) I know, but it would be useful if this could be updated, Thanks!
    ________________________________________
    14:19 < cycrosism> I wonder what she would have done without it
    14:19 < cycrosism> without me*
    Cycrosism is now an it.
    Quote Originally Posted by Dervish View Post
    /Facedesk.

  5. #5
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    I guess I could. I'll see if I have time to update it in the week.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  6. #6
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Could you put something about CTS in?
    Ce ne sont que des gueux


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
  •