Page 1 of 2 12 LastLast
Results 1 to 25 of 32

Thread: Autocoloring / Object finding using TAutoColorInfo(TAI).

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

    Default Autocoloring / Object finding using TAutoColorInfo(TAI).

    As of SRL rev #18 we have a record in SRL called TAutoColorInfo. Basically this records holds a lot of parameters, which some functions can use to auto color or find an object.

    As of rev #18 the TAutoColorInfo record looks like this :

    SCAR Code:
    type
      TAutoColorInfo = record
        Name: string;
        Color: Integer;
        MinCount: Integer;
        MaxCount: Integer;
        MaxDist: Integer;
        MaxDistCenter: Integer;
        UpText: string;
        HueMod, SatMod: Extended;
        LumTol: Integer;
        MinR, MaxR, MinG, MaxG, MinB, MaxB: Integer;
        MinX, MaxX, MinY, MaxY, MinZ, MaxZ: Extended;
    end;

    For those of you that do not know what a record is I suggest you read this tutorial

    Basically we throw so many parameters at the function that you pretty much only get the color you want.

    *note : just because TAutoColorInfo can contain all these values doesn't mean you have to fill them all in. However you do have to fill in most of them.

    Using a TAutoColorInfo
    Using a TAutoColorInfo is very simple and quick when you know what to do. Once you have loaded your TAutoColorInfo you can use it in any of the following functions :

    Code:
    function FindObjRecordEx(var  fx, fy: Integer; AutoInfo: AutoColorInfo; QuickSorting, RGBXYZCheck: Boolean): Boolean; 
    function FindObjRecord(var  fx, fy: Integer; AutoInfo: TAutoColorInfo): Boolean;
    function FindColorRecordEx(var  rx, ry: Integer; ColorRecord: TAutoColorInfo; x1, y1, x2, y2: Integer; RGBXYZCheck: Boolean): Integer; 
    function FindColorRecord(var  rx, ry: Integer; ColorRecord: TAutoColorInfo): Integer;
    *QuickSorting : With QuickSorting on the function divides the TPoints it found using TPAtoATPA, otherwise it uses SplitTPA. TPAtoATPA splits the points by taking one point, create a box around it and any point within that box belongs to that division. SplitTPA first looks at the first point, creates a box around it, much like TPAtoATPA, but then it looks at the second point in that division, creates a box around it, third point ... etc.

    *RGBXYZCheck : With this on, it also checks the RGB and XYZ values, instead of just the HSL values.

    Loading a TAutoColorInfo is just the same as loading any other record, here is an example of a varrockroad-TAutoColorInfo, using FindColorRecord we get the RoadColor.

    SCAR Code:
    program FindColorRecordExample;
    {.include SRL\SRL.scar}

    var
      x, y: Integer;
      ColorRecord: TAutoColorInfo;

    begin
      SetupSRL;

      with ColorRecord do
      begin
        Name := 'Varrock Road';
        MinCount := 100;
        Color := 7633790;
        HueMod := 0.63;
        SatMod := 0.11;
        LumTol := 8;
        MinR := 106; MaxR := 146;
        MinG := 102; MaxG := 144;
        MinB := 97; MaxB := 136;
        MinX := 13.10; MaxX := 25.89;
        MinY := 13.69; MaxY := 27.43;
        MinZ := 13.49; MaxZ := 26.86;
      end;

      Writeln(IntToStr(FindColorRecord(x, y, ColorRecord)));
    end.

    Yes it is as easy as that, create your TAI (TAutoColorInfo) variable, load it and use the function. Here follows another example for finding the ladder on the main screen :

    SCAR Code:
    program FindObjRecordExample;
    {.include SRL\SRL.scar}

    var
      x, y: Integer;
      ObjectRecord: TAutoColorInfo;

    begin
      SetupSRL;

      with ObjectRecord do
      begin
        Name := 'Main Screen Ladder';
        UpText := 'Climb';
        MaxDist := 15;
        Color := 2838120;
        HueMod := 0.09;
        SatMod := 1.55;
        LumTol := 4;
        MinR := 95; MaxR := 122;
        MinG := 69; MaxG := 90;
        MinB := 33; MaxB := 53;
        MinX := 7.28; MaxX := 11.91;
        MinY := 6.96; MaxY := 11.41;
        MinZ := 2.46; MaxZ := 4.71;
      end;

      FindObjRecord(x, y, ObjectRecord);
    end.

    *tip : Loading a TAI everytime you want to use it does not look very clean. It is advised to load it once globally, much like you load some bitmaps globally.

    Creating a TAI
    Now you might think how in the world am I supposed to get all those values . I agree, getting those manually is a pain in the *ss so I added a new function in ACA (AutoColorAid) that does the trick for you. If you have SRL rev#18 on your pc, in the standard location, ACA should be located here : C:\Program Files\SCAR 3.15\Includes\SRL\Scripting Tools\Auto Color Aid v2.exe . Unfamiliar with ACA ? Read this.

    You simply follow the instructions in that thread but instead of creating a function you create a TAI through the FindColorRecord or FindObjRecord tabs.

    TAI's in SRL
    TAI's are already being used in SRL. The frog cave solver for examples uses some TAI's. This is all fine and dandy to know, but I guess it is hardly of any interest to you, what you however might like to know is the TAI's I've put in Mining.scar. There are 2 functions in Mining.scar,

    Code:
    function  FindObjRockEx(var cx, cy: Integer; RockIndex: Integer; QuickSorting, RGBXYZCheck: Boolean): Boolean;
    function  FindObjRock(var cx, cy: Integer; RockIndex: Integer): Boolean;
    You can use these using a couple of set TAutoColorInfo's in Mining.scar, just by telling what rock you want it to mine . Take a look at this script for example :

    SCAR Code:
    program New;
    {.include SRL\SRL.scar}
    {.include SRL\SRL\skill\Mining.scar}

    var
      x, y: Integer;
     
    begin
      SetupSRL
      SetupMining;
     
      FindObjRock(x, y, rimmington_Iron);
    end.

    That will find rimmington iron rocks. Here is the list with all possible entries for the rock index (in the example this is rimmington_Iron) :

    Code:
      rimmington_Clay
      rimmington_Copper
      rimmington_Tin
      rimmington_Iron
      rimmington_Gold
      
      old_Clay
      old_Copper
      old_Tin
      old_Iron
      old_Coal
      old_Mithril
      old_Adamant
      
      varrock_Clay
      varrock_Copper
      varrock_Tin
      varrock_Iron
      varrock_Silver
      
      lumbridge_Copper
      lumbridge_Tin
      lumbridge_Coal
      lumbridge_Mithril
      lumbridge_Adamant
      
      falador_Clay
      falador_Copper
      falador_Tin
      falador_Iron
      falador_Coal
      falador_Mithril
      falador_Adamant
    I can imagine all of this may sound a bit like a foreign language to some people, if you need any clarification on some topic please do post here and I will adjust the tutorial.
    Administrator's Warning:


  2. #2
    Join Date
    Dec 2006
    Posts
    907
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    Amazing! Thanks SRL Dev and Sumilion! Looks like I can test this out on my upcomming Power Or Bank Multi - Mine! You guys are AWSOME!

  3. #3
    Join Date
    May 2008
    Location
    127.0.0.1
    Posts
    704
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    wow that is just what i need for lumby stairs!
    E: You need to update ACA?
    <Wizzup> And he's a Christian
    <Wizzup> So he MUST be trusted
    ___________________________________________
    <Wizzup> she sounds like a dumb bitch

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

    Default

    Quote Originally Posted by Rubix View Post
    wow that is just what i need for lumby stairs!
    E: You need to update ACA?
    Yeh the one that is in rev #17 or the one that you can download here on the forums will not have this function.
    Administrator's Warning:


  5. #5
    Join Date
    Dec 2006
    Posts
    907
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    what with the mincount and lumtol? i know part of lumtol means tolerance =p

  6. #6
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,563
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    GOOD Job Mate, Damn Good Job!
    ~Hermen

  7. #7
    Join Date
    May 2008
    Location
    127.0.0.1
    Posts
    704
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    without this, i wouldnt have been able to finish my flax spinner :P finds the stairs, the spinning wheel, and even finds the "spin bowstring" button 1337
    <Wizzup> And he's a Christian
    <Wizzup> So he MUST be trusted
    ___________________________________________
    <Wizzup> she sounds like a dumb bitch

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

    Default

    Quote Originally Posted by deathscytex View Post
    what with the mincount and lumtol? i know part of lumtol means tolerance =p
    LumTol = LumTol
    HueTol = HueMod * LumTol
    SatTol = SatMod * LumTol

    familiar with the HSL color range ? If not I suggest searching for a tutorial here.

    Mincount is the minimum amount of pixels an object should have before it will move the mouse to it, or the minimum amount something must have before it is a valid color (in FindColorRecord(Ex)).
    Administrator's Warning:


  9. #9
    Join Date
    Oct 2007
    Location
    If (Online) then Loc := ('On comp') else Loc := ('Somewhere else!');
    Posts
    2,020
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wow very nice and very hand

    good job man

  10. #10
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,488
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    This will be fun to work with, good job!

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  11. #11
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,563
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    LOL, i don't got ACA <TheNEwestVErsion> in my scripting tools =/
    ~Hermen

  12. #12
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,841
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Quote Originally Posted by Hermpie View Post
    LOL, i don't got ACA <TheNEwestVErsion> in my scripting tools =/
    Delete SRL Folder && checkout SVN.


    Epic tut Sumilionio.


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  13. #13
    Join Date
    Dec 2006
    Posts
    907
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    I made this without the ACA. (I used the old ACA before i foudn out there was ACA V2)

    SCAR Code:
    function LightingPoint : Boolean;
    var
      x, y : Integer;
      ColorRecord : TAutoColorInfo;
    begin
      if (not (LoggedIn)) then Exit;
      with ColorRecord do
      begin
        Name := 'Camelot Road';
        MinCount := 50;
        Color := 7697533;
        HueMod := 0;
        SatMod := 0;
        LumTol := 5;
        MinR := 42; MaxR := 82;
        MinG := 52; MaxG := 92;
        MinB := 6; MaxB := 46;
        MinX := -10; MaxX := 20;
        MinY := -9; MaxY := 21;
        MinZ := -13; MaxZ := 17;
      end;
      Writeln(IntToStr(FindColorRecord(x, y, ColorRecord)));
      if (FindColorRecord(x, y, ColorRecord) = 0) then LogOut;
      RoadColor := FindColorRecord(x, y, ColorRecord);
      RadialRoadWalk(RoadColor, 160, 190, 62, 1, 1);
      FFlag(2);
      Wait(330 + Random(275));
      Result := True;
    end;

    Well, I put this on my Maple Forest Fire (Woodcutting Maples, FireMaking). Im trying to walk to the Road in Camelot... And lets just say... This TAutoColor was not much of a help... Unless you can find any errors in this function much? Because this is what appears in my DeBug.

    ****** ******
    Creating the NickTPA.
    0
    ________________________________________
    [ ]
    [ Maple Forest Fire Progress ]
    [ Report Version 1 ]
    [ Time Elapsed : 1 Minutes and 1 Seconds
    [ Loads Finish : 0
    [ Ents Found : 0
    [ Loads Banked : 0
    [ Loads Burnt : 0
    [ Please Post This Report! ]
    [______________________________________]
    ******* *******
    0
    So it kept finding 0, so i made the script LogOut the character so the colours refresh. Than at the third try, it failed, but i stopped the script and checked the Road Color just to be sure.

    Color Picked: 7500411 at (651, 105)
    ........ The color i specified shouldve been close enough to the new Road Color.... Did i do something wrong?!

  14. #14
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,702
    Mentioned
    145 Post(s)
    Quoted
    129 Post(s)

    Default

    XYZ range from 0 to 100, they never go negative.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  15. #15
    Join Date
    Jan 2007
    Location
    Nomming bits in your RAM
    Posts
    385
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Great tutorial. Can you please elaborate on the following values, please?
    QuickSorting
    RGBXYZCheck

    Thanks. This will definately help in my tutorial island script.

    ~Macro
    Current Project: Catching up. XD. Potentially back for the summer, depending on how things go.

  16. #16
    Join Date
    Dec 2006
    Posts
    907
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    XYZ range from 0 to 100, they never go negative.
    But i read a guide

    -20 for RGB
    -15 XYZ
    -10 for i forgot the other one, HSL i think.

    But thanks Wizzup?!

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

    Default

    Quote Originally Posted by Macro_FTW View Post
    Great tutorial. Can you please elaborate on the following values, please?
    QuickSorting
    RGBXYZCheck

    Thanks. This will definately help in my tutorial island script.

    ~Macro
    With QuickSorting set to true, the function uses ararP := TPAtoATPA(arAP, MaxDist). Otherwise, it uses ararP := SplitTPA(arAP, MaxDist);. TPAtoATPA groups the points in the array into boxes of the given MaxDist (box dimensions) while SplitTPA groups the points that are a certain maximum distance apart from each other.

    The RGBXYZCheck just allows the function to narrow down the points in the array to be more accurate. It would probably be best to leave that on, especially if you're trying to find an object like a rock (using FindObjRock for example).
    :-)

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

    Default

    Quote Originally Posted by deathscytex View Post
    I made this without the ACA. (I used the old ACA before i foudn out there was ACA V2)

    SCAR Code:
    function LightingPoint : Boolean;
    var
      x, y : Integer;
      ColorRecord : TAutoColorInfo;
    begin
      if (not (LoggedIn)) then Exit;
      with ColorRecord do
      begin
        Name := 'Camelot Road';
        MinCount := 50;
        Color := 7697533;
        HueMod := 0;
        SatMod := 0;
        LumTol := 5;
        MinR := 42; MaxR := 82;
        MinG := 52; MaxG := 92;
        MinB := 6; MaxB := 46;
        MinX := -10; MaxX := 20;
        MinY := -9; MaxY := 21;
        MinZ := -13; MaxZ := 17;
      end;
      Writeln(IntToStr(FindColorRecord(x, y, ColorRecord)));
      if (FindColorRecord(x, y, ColorRecord) = 0) then LogOut;
      RoadColor := FindColorRecord(x, y, ColorRecord);
      RadialRoadWalk(RoadColor, 160, 190, 62, 1, 1);
      FFlag(2);
      Wait(330 + Random(275));
      Result := True;
    end;

    Well, I put this on my Maple Forest Fire (Woodcutting Maples, FireMaking). Im trying to walk to the Road in Camelot... And lets just say... This TAutoColor was not much of a help... Unless you can find any errors in this function much? Because this is what appears in my DeBug.



    So it kept finding 0, so i made the script LogOut the character so the colours refresh. Than at the third try, it failed, but i stopped the script and checked the Road Color just to be sure.



    ........ The color i specified shouldve been close enough to the new Road Color.... Did i do something wrong?!
    Yes I'd suggest recreating the TAI using ACA v2 cause that TAI is just not right. Not only the XYZ are negatives, but the Hue and Sat mods are 0, which means Hue Tolerance is 0 and Saturation Tolerance is 0, which in turn means it will not find many colors, most likely only 7697533 and if it won't find any color it returns 0.

    Quote Originally Posted by Macro_FTW View Post
    Great tutorial. Can you please elaborate on the following values, please?
    QuickSorting
    RGBXYZCheck

    Thanks. This will definately help in my tutorial island script.

    ~Macro
    Quote Originally Posted by Method View Post
    With QuickSorting set to true, the function uses ararP := TPAtoATPA(arAP, MaxDist). Otherwise, it uses ararP := SplitTPA(arAP, MaxDist);. TPAtoATPA groups the points in the array into boxes of the given MaxDist (box dimensions) while SplitTPA groups the points that are a certain maximum distance apart from each other.

    The RGBXYZCheck just allows the function to narrow down the points in the array to be more accurate. It would probably be best to leave that on, especially if you're trying to find an object like a rock (using FindObjRock for example).
    He is right, I also added a small explanation at the first post about it.
    Administrator's Warning:


  19. #19
    Join Date
    Dec 2006
    Posts
    907
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    Well Sumilion. problem is with the ACA V2, when i click on the road color, the huemod is 0 and etc.

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

    Default

    Quote Originally Posted by deathscytex View Post
    Well Sumilion. problem is with the ACA V2, when i click on the road color, the huemod is 0 and etc.
    True, then you have only selected one color. The power of ACA lies in the ability to take the average from all the colors you've put in, and calculate what tol it needs to be similar to each color you've put in. So the more colors you've entered in ACA, the bigger the chance it will find the color you want. You're using ACA to find the road color ? I suggest going into a world, pick the road color, logout + login, pick it again, switch worlds and repeat.
    Administrator's Warning:


  21. #21
    Join Date
    Dec 2006
    Posts
    907
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    Oh, thanks Sumilion! I'll see you in the SRL Application Forms soon.

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

    Default

    Quote Originally Posted by deathscytex View Post
    Oh, thanks Sumilion! I'll see you in the SRL Application Forms soon.
    Will you now ? glad I could help
    Administrator's Warning:


  23. #23
    Join Date
    Mar 2007
    Posts
    1,699
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    What's the advantage of using this over normal autocoloring/object finding?

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

    Default

    Its fast to make and easily adjustable.
    Administrator's Warning:


  25. #25
    Join Date
    Dec 2006
    Posts
    907
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    Is it the same reliability as a regular Auto Color?

    And also, i got accepted in SRL Members! Check me out! Look so cool. (You can see the difference =3)

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. need help finding object
    By Baked0420 in forum OSR Help
    Replies: 13
    Last Post: 12-15-2008, 01:27 AM
  2. Finding A Object!
    By RiSe AgAiNsT in forum OSR Help
    Replies: 2
    Last Post: 07-17-2007, 07:22 AM

Posting Permissions

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