Results 1 to 7 of 7

Thread: Finding Colour on a tile?

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

    Default Finding Colour on a tile?

    Is it possible to have a TTile, and then search for a colour on the bounds of that tile?
    It'd have to be reflection though.

    I'm trying this as a means of getting around the lack of model support, for objects that have holes in them, or similar. (things like railings etc).
    ________________________________________
    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.

  2. #2
    Join Date
    Dec 2010
    Posts
    808
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    So you want to search for a colour in a tile with reflection... no.

  3. #3
    Join Date
    Oct 2006
    Location
    finland, helsinki
    Posts
    2,501
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Simba Code:
    Var
      Tile: TTile;
      MSPoint: TPoint;

    Begin
      Tile := Tile(3030, 3030); //example
      MSPoint := TileToMS(Tile, 0);
      FindColorsTolerance(TPA, Color, MSPoint.X - 10, MSPoint.Y - 10, MSPoint.X + 10, MSPoint.Y + 10, Tolerance);
    End.

    Thats how I would do it

    Code:
    • Narcle: I recall Jukka releasing a bunch of scripts like this before... Its how he rolls I think. rofl
    • Solarwind: Dude, you are like... t3h s3x.
    • Hy71194: JuKKa you're a machine! You released 3 scripts in 10 minutes! :O
    • benjaa: woah.... Jukka is the man Guildminer pwns all
    • NaumanAkhlaQ: And JuKKa Is my Her0!

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

    Default

    Thanks JuKKa, I presume that the MM would have to be set to the highest angle for this to work though, without incorporating some harder math to work out the offset due to height etc.
    ________________________________________
    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
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    This should be better since it takes top left and bottom right of tile:
    Var
    TPA: TPointArray;
    Topleft, Downright: TPoint;
    Begin
    TopLeft := TileToMSEx(Tile(69, 69), 0, 0, 0);
    Downright := TileToMSEx(Tile(69, 69), 1, 1, 0);
    FindColorsTolerance(TPA, Color, TopLeft.x, Topleft.y, DownRight.x, Downright.y, 15);
    End.

  6. #6
    Join Date
    Dec 2010
    Posts
    808
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    FindColorsSpiralTolerance
    iirc

    Then set your boundaries

  7. #7
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by HarryJames View Post
    ...for objects that have holes in them, or similar. (things like railings etc).
    You can get an object at a certain tile whether it be interactable / ground object / wall object / or decoration (I believe). Basically, if the object has any kind of a right-click menu at all (even 'examine' only) then it's interactable, so the 'railings' you're referring to might be a ground object because they're placed on the base tile, like you said, but doesn't have a right-click menu therefore it's not interactable.

    Now if you're determined to use color inside that tile's box then I'm sure you could look at SRL's method for converting the Reflection tile to your screen position in the form of a box.

    Simba Code:
    function TileToMSEx(tile: TTile; offx, offy : extended; height : integer) : TPoint;
    var
      pixelX, pixelY, pixelZ: extended;
    begin
      pixelX:= (tile.x - SmartGetFieldInt(0,hook_static_BaseX) + offX) * 512.0;
      pixelY:= GetTileHeight(tile) - height;
      pixelZ:= (tile.y - SmartGetFieldInt(0,hook_static_BaseY) + offY) * 512.0;
      Result := World3DToScreen(pixelX, pixelY, pixelZ);
      if not PointInBox(Result, IntToBox(MSX1, MSY1, MSX2, MSY2))then
      begin
        Result.x := -1;
        Result.y := -1;
      end;
    end;

    That returns a point which would be the absolute center of your tile. You'd have to look look through "World3DToScreen" or whatever to find the distance from that center point to the edge of the tile (in any direction), this will give you the radius and you can use that to find the box's XS/YS and XE/YE. Then just search within those parameters for your color.

    I'm sorry if I'm a bit unclear, but I am trying to explain it as straight-forward as possible.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


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
  •