Results 1 to 22 of 22

Thread: Autocoloring non-static colors...

  1. #1
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Autocoloring non-static colors...

    SCAR Code:
    Function AutoColorIt(Color : TColor): Integer;
    Var
      TPA, TPA2 : TPointArray;
      I, J, bestCol, maxTol : Integer;
      Cols : TIntegerArray;
    Begin
      SetLength(TPA2, 0);
      FindColorsTolerance(TPA, Color, MMX1, MMY1, MMX2, MMY2, 25);
      For I := 0 To High(TPA) Do
        If rs_OnMinimap(TPA[I].X, TPA[I].Y) Then
        Begin
          SetArrayLength(TPA2, Length(TPA2) + 1);
          TPA2[High(TPA2)] := TPA[I];
        End;
      Cols := GetColors(TPA2);
      maxTol := 50;
      For I := 0 To High(Cols) Do
        If SimilarColors(Cols[I], Color, maxTol) And (Cols[I] <> bestCol) Then
        Begin
          bestCol := Cols[I];
          For J := 0 To 442 Do
            If SimilarColors(bestCol, Color, J) Then
            Begin
              maxTol := J;
              Break;
            End;
        End;
      If maxTol > 30 Then
        Exit;
      Result := bestCol;
      Writeln('Max Tolerance Found = ' + IntToStr(maxTol));
      Writeln('Color = ' + IntToStr(Color));
    End;
    Autocolors non-static colors. Checks for the best tolerance and color. No need for tolerance or other specifications, just insert the color.
    Now, some pics:
    WaterColor:


    Trees(in MM):


    RoadColor:




  2. #2
    Join Date
    Nov 2006
    Location
    'Pergamino, BA, Argentina';
    Posts
    473
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Yeah latin power. I'd use this at my Junior Members competition but it would be against the rules. I'll give it a try later when i need to make some walking, and post a nice feedback of how it worked.

  3. #3
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    wow... completely missed this, nice cazax! i might use this on my next project... success rate?

  4. #4
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I'm confused on how to use =X

  5. #5
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    SCAR Code:
    i := AutoColorIt(color);
    if RadialRoadWalk(i, start, end, radius, xmod, ymod) then blah;

  6. #6
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ???

    still confused

  7. #7
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    if RadialRoadWalk(AutoColorIt(Color), start, end, radius, xmod, ymod) then blah;

    I don't understand it either. If it's static, you don't need to autocolor it? :/.

    ~Sandstorm

  8. #8
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Sandstorm View Post
    SCAR Code:
    if RadialRoadWalk(AutoColorIt(Color), start, end, radius, xmod, ymod) then blah;

    I don't understand it either. If it's static, you don't need to autocolor it? :/.

    ~Sandstorm
    You need to autocolor because it will change... by autocoloring static colors i meant you just use a color without a tolerance.


  9. #9
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Oh xD. I get it now. Sorry!

    ~Sandstorm

  10. #10
    Join Date
    Dec 2007
    Location
    Indiana
    Posts
    85
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Im testing it now in my current project.

    works way better than what i was using before. You're gunna get credit when i release.
    Current Project:
    *Massive Multi-Miner*

    if (not(OnSrlForums)) then
    begin
    CheckBed;
    CheckWork;
    end;

  11. #11
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    I'm a bit confused about this line:
    SCAR Code:
    For J := 0 To 442 Do
    Why 442? That would result in any color matching, no matter how far apart they are.

  12. #12
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    isn't 442 the maxtol for anything...? or is that 255?

  13. #13
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    442 is the max tolerance in CTS 1.


  14. #14
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Good Work, just a hint. Couldn't you change the TColor to an Integer???

  15. #15
    Join Date
    Jul 2007
    Location
    Missouri
    Posts
    318
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    He uses the TInteger because he is using it in a tpa, if it was just an integer, he would not be able to run through the tpa looking for the similar colors

    i think? lol.

  16. #16
    Join Date
    Dec 2007
    Location
    Indiana
    Posts
    85
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Cazax View Post



    Trees(in MM):


    RoadColor:

    quick question: what program did you use to find the matching colors in your pictures?
    Current Project:
    *Massive Multi-Miner*

    if (not(OnSrlForums)) then
    begin
    CheckBed;
    CheckWork;
    end;

  17. #17
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by massive630 View Post
    quick question: what program did you use to find the matching colors in your pictures?
    I use DebugTPA by Wizzup:
    SCAR Code:
    Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;

    Var
       Width, Height, ClientBMP, I: Integer;
       xs, ys, xe, ye: Integer;

    Begin
      Try
      Begin
        xe := xs xor xs;
        ye := ys xor ys;
        xs := 1 shl 20;
        ys := 1 shl 20;

        For I := 0 To High(Points) Do
        Begin
          xs := Min(xs, Points[i].X);
          ys := Min(ys, Points[i].Y);

          xe := Max(xe, Points[i].X);
          ye := Max(ye, Points[i].Y);
        End;

        Width := xe - xs;
        Height := ye - ys;

        DisplayDebugImgWindow(0, 0);
        DisplayDebugImgWindow(Width, Height);
        ClientBMP := BitmapFromString(Width, Height, '');

        CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
        For I := 0 To High(Points) Do
          FastSetPixel(ClientBMP, Points[i].X - xs, Points[i].Y - ys, 255);
        If BmpName <> '' Then
          SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
        SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
        DisplayDebugImgWindow(Width, Height);

        FreeBitmap(ClientBMP);
      End
      Except
        FreeBitmap(ClientBMP);
      End;
      Result := True;
    End;


  18. #18
    Join Date
    Dec 2007
    Location
    Indiana
    Posts
    85
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Cazax View Post
    I use DebugTPA by Wizzup:
    SCAR Code:
    Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;

    Var
       Width, Height, ClientBMP, I: Integer;
       xs, ys, xe, ye: Integer;

    Begin
      Try
      Begin
        xe := xs xor xs;
        ye := ys xor ys;
        xs := 1 shl 20;
        ys := 1 shl 20;

        For I := 0 To High(Points) Do
        Begin
          xs := Min(xs, Points[i].X);
          ys := Min(ys, Points[i].Y);

          xe := Max(xe, Points[i].X);
          ye := Max(ye, Points[i].Y);
        End;

        Width := xe - xs;
        Height := ye - ys;

        DisplayDebugImgWindow(0, 0);
        DisplayDebugImgWindow(Width, Height);
        ClientBMP := BitmapFromString(Width, Height, '');

        CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
        For I := 0 To High(Points) Do
          FastSetPixel(ClientBMP, Points[i].X - xs, Points[i].Y - ys, 255);
        If BmpName <> '' Then
          SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
        SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
        DisplayDebugImgWindow(Width, Height);

        FreeBitmap(ClientBMP);
      End
      Except
        FreeBitmap(ClientBMP);
      End;
      Result := True;
    End;
    Wow thanks. I hate to ask, but i guess ive gotta ask to learn: how in gods name would i use this?
    Current Project:
    *Massive Multi-Miner*

    if (not(OnSrlForums)) then
    begin
    CheckBed;
    CheckWork;
    end;

  19. #19
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    a TPA is an array of tpoints, so you just input your points:
    SCAR Code:
    DebugTPA(Points, '');
    You can change '' to something and it will save it as a bitmap.


    Example:
    SCAR Code:
    procedure Debug;
    Var
      TPA : TPointArray;
    Begin
      FindColorsTolerance(TPA, Color, X1, Y1, X2, Y2, Tol);
      DebugTPA(TPA, '');
    End;


  20. #20
    Join Date
    Dec 2007
    Location
    Indiana
    Posts
    85
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wow Cazex thanks alot. you've been very helpful. Rep.
    Current Project:
    *Massive Multi-Miner*

    if (not(OnSrlForums)) then
    begin
    CheckBed;
    CheckWork;
    end;

  21. #21
    Join Date
    Dec 2006
    Posts
    173
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice function! Could I use this in my upcoming script? I'll make sure to credit.
    Starting to merchant, if you know of any good clans, PM me please.

  22. #22
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Static Arrays!!!!
    By Naum in forum OSR Beginner Scripting Tutorials
    Replies: 26
    Last Post: 06-17-2012, 07:49 PM
  2. static errors?
    By lardmaster in forum Java Help and Tutorials
    Replies: 10
    Last Post: 01-12-2007, 10:27 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
  •