Results 1 to 23 of 23

Thread: Function FindColorPriority

  1. #1
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Function FindColorPriority

    This is, i guess, my first, finished function.

    Special thanks to StarBlaster100 for helping me with tarrays

    It will find the first color, but if it doesn't find that, it will find the next color.

    Im not really sure what it is usefull for, but watever lol. I dont think it has already been created...

    Tell me if you like it! I might make some more functions to help my fellow scripters, in the future!

    here it is:

    SCAR Code:
    ////////////////////\\\\\\\\\\\\\\\\\\\\\
                  ///////////Find Color Priority\\\\\\\\\\\\\
                 //////////All Credit to Macrosoft\\\\\\\\\\\\
                //Please do NOT copy without giving me credit\\
               //Special Thanks to StarBlaster100 for his help\\
    {***********************************************************************************************
    Function FindColorPriority(var x, y: Integer; Colors: TIntegerArray; Tolerance: Integer; xs, ys, xe, ye: LongInt): Integer;

    Example of use: FindColorPriority(x, y, [22023, 0000], 5, 12, 34, 67, 34)
    By: Macrosoft
    Description:  Will find a color, if the color is not found it will move
    to the next color.  If it returns 0, it found none of the colors,
    otherwise it will return the color number (1,2,3,4,5,6, etc.; not 29849283749, 230920432984, etc.)
    It Will also return the x and y coords of the color
    I may make more priority Functions such as DoFunctionPriority,
    FindObjectPriority, etc.
    Tell me if you like it! Also, notify me for me improvements and errors.
    Make sure you include SRL
    ********************************************************************************************************}

    {.include SRL/SRL.scar}
    Function FindColorPriority(var x, y: Integer; Colors: TIntegerArray; Tolerance: Integer; xs, ys, xe, ye: LongInt): Integer;
      var
       Counter: Integer;
      begin
        GetArrayLength(Colors);
        Counter:=0
        repeat
          begin
            if(FindColorTolerance(x, y, Colors[Counter], xs, ys, xe, ye, Tolerance)=True) then
              begin
                Result:= Counter + 1;
                Exit;
            end else
              Counter:=Counter +1;
          end;
        until(GetArrayLength(Colors)=Counter);
        begin
          if(GetArrayLength(Colors)=Counter) then
           Result:=0
        end;
      end;

  2. #2
    Join Date
    Mar 2006
    Location
    USA
    Posts
    948
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    You dont need NumberOfColors: integer; you just need to use GetArrayLength(Array);

  3. #3
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh, thanks, ill fix that in the morning, its 2 am here... anyway, any scripter who can use the function can probable fix that themselves anyway

  4. #4
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    SCAR Code:
    function FindColorPriority(var x, y: Integer; Colors: TIntegerArray; Tolerance, xs, ys, xe, ye: Integer): Integer;
    begin
      for Result := 1 do Length(Colors) -1 do
        if(FindColorTolerance(x, y, Colors[i -1], xs, ys, xe, ye, Tolerance))then
          Exit;
      Result:=0;
    end;

    With array you mostly use for to do, tell me if I need to explain it
    Hup Holland Hup!

  5. #5
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Nielsie you screwd up, like everyone uses SetArrayLength and it makes the array from 0 to X, so you do for I := 0 to Length(Array) - 1 do

    Go get sum coffee =)

  6. #6
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    (FindColorTolerance(x, y, Colors[Counter], xs, ys, xe, ye, Tolerance)=True)

    You don't need =True...it confused the hell out of me because I thought you were trying to make a sad face with the bracket and equals sign
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  7. #7
    Join Date
    Apr 2007
    Location
    England
    Posts
    83
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    SCAR Code:
    function FindColorPriority(var x, y: Integer; Colors: TIntegerArray; Tolerance, xs, ys, xe, ye: Integer): Integer;
    begin
      for Result := 1 do Length(Colors) -1 do
        if(FindColorTolerance(x, y, Colors[i -1], xs, ys, xe, ye, Tolerance))then
          Exit;
      Result:=0;
    end;

    With array you mostly use for to do, tell me if I need to explain it
    If we only have 2 colors (I know), length(colors)-1 would equal 1. Therefore, as soon as you start, you will only have gone through the loop once, and on the last entry as well. Unless I'm wrong?

    Here's how I would have changed it:

    SCAR Code:
    function FindColorPriority(var x, y: Integer; Colors: TIntegerArray; Tolerance, xs, ys, xe, ye: Integer): Integer;
    begin
      for Result := 0 do Length(Colors) -1 do
        if(FindColorTolerance(x, y, Colors[result], xs, ys, xe, ye, Tolerance))then
          Exit;
      Result:=0;
    end;

    So not much of a change, but it would work in my eyes.

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

    Default

    looks nice i guess.. but there are familiar functions in srl?
    ~Hermen

  9. #9
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Quote Originally Posted by Distort View Post
    If we only have 2 colors (I know), length(colors)-1 would equal 1. Therefore, as soon as you start, you will only have gone through the loop once, and on the last entry as well. Unless I'm wrong?

    Here's how I would have changed it:

    SCAR Code:
    function FindColorPriority(var x, y: Integer; Colors: TIntegerArray; Tolerance, xs, ys, xe, ye: Integer): Integer;
    begin
      for Result := 0 do Length(Colors) -1 do
        if(FindColorTolerance(x, y, Colors[result], xs, ys, xe, ye, Tolerance))then
          Exit;
      Result:=0;
    end;

    So not much of a change, but it would work in my eyes.
    Yes, I know.. But the result would be different from the original function... So I started with Result := 1, but I forgot to take of the -1
    Hup Holland Hup!

  10. #10
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    whoa!, lots of replys, ill look at them later, im on vacation

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

    Default

    btw i ment simlliar not the word with the F
    ~Hermen

  12. #12
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    Well... I guess it could have a use, but I like lots of complicated math instead.
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  13. #13
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok, im guna change the script soon, almost done

  14. #14
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default

    As a matter of fact, I would like to have a function that scans for the unique color of a NPC, a goblin for instance. You scan the color under Uptext Attack Goblin, and compare it to colors in mainscreen. You collect the unique Colors of Goblins. Then you set your General colortolerance for NPC finding to tol = 1. The Mouse wont hoover over anything else but your Goblin now.
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

  15. #15
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Quote Originally Posted by WT-Fakawi View Post
    As a matter of fact, I would like to have a function that scans for the unique color of a NPC, a goblin for instance. You scan the color under Uptext Attack Goblin, and compare it to colors in mainscreen. You collect the unique Colors of Goblins. Then you set your General colortolerance for NPC finding to tol = 1. The Mouse wont hoover over anything else but your Goblin now.
    Boreas has made such a script.. You enter a few small bitmaps of your NPC and the script gets you the best color(s) It's in this section + in Auto Color Aid.
    Hup Holland Hup!

  16. #16
    Join Date
    Apr 2007
    Location
    Australia
    Posts
    4,163
    Mentioned
    9 Post(s)
    Quoted
    19 Post(s)

    Default

    Quote Originally Posted by WT-Fakawi View Post
    As a matter of fact, I would like to have a function that scans for the unique color of a NPC, a goblin for instance. You scan the color under Uptext Attack Goblin, and compare it to colors in mainscreen. You collect the unique Colors of Goblins. Then you set your General colortolerance for NPC finding to tol = 1. The Mouse wont hoover over anything else but your Goblin now.
    What I did to make my script avoid hovering over muggers in my miner was this - if it finds the colour of the ore, it checks for the unique colour of the mugger in a 20 x 20 box around it, if it finds that colour then we can safely say that its a mugger so we dont move our mouse there. You could do that with an array of colours too, in case there are more colours around on the ground that are similar to goblins. Or you could find 1 colour of the goblin, then search for another colour in 20 x 20, then search for yet another in a 20 x 20. If it finds all three then we know its a goblin. Not as advanced as what you guys are talking about though lol

  17. #17
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    That might be nice. I guess I could try and then find out someone else made one...


    @N3ss3s - GetArrayLength() is faster with arrays than Length(), which was originally for strings. (I think it tests if its an array or something... Stupid IF's!).
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  18. #18
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i dont think someone already made it...

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

    Default

    Quote Originally Posted by r0b0t1 View Post
    That might be nice. I guess I could try and then find out someone else made one...


    @N3ss3s - GetArrayLength() is faster with arrays than Length(), which was originally for strings. (I think it tests if its an array or something... Stupid IF's!).
    Incorrect. I tested the speed of them a few weeks ago, and they (length and getarraylength) came out to exactly the same speed.

  20. #20
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ill just stay with getarraylength

    WOOT, I can actually get on to this forum now lol

    TY WT-Fakawai

  21. #21
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    lovin the idea, but as already stated before you don't need the =True because the function already returns a boolean when you call it.
    SCAR Code:
    if(FindColorTolerance(x, y, Colors[Counter], xs, ys, xe, ye, Tolerance)=True) then

    ~RMagician

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  22. #22
    Join Date
    Mar 2007
    Posts
    674
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Pretty nice function. I cant test it tho...

  23. #23
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thanks

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need help with a function.
    By Floor66 in forum OSR Help
    Replies: 15
    Last Post: 04-15-2008, 02:03 PM
  2. Replies: 2
    Last Post: 02-27-2008, 05:20 PM
  3. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  4. [FUNCTION] FindDoorColour: integer; By ZephyrsFury [FUNCTION]
    By ZephyrsFury in forum Research & Development Lounge
    Replies: 10
    Last Post: 07-27-2007, 08:45 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
  •