Terrain Tags edit [resolved]

EDIT: Unsurprisingly, I managed to fix this (once again) right after I posted a support topic. >:E
Very well, I guess you can just review/critique this scriptlet.





I'm working on modifying the default "Game_Map" script under terrain tags. Currently the program does not recognize events with tileset graphics as having terrain tags, and I'd like to correct this.

Here's the default code:
  1. class Game_Map
  2.  
  3.   def terrain_tag(x, y)
  4.     if @map_id != 0
  5.       for i in [2, 1, 0]
  6.         tile_id = data[x, y, i]
  7.         if tile_id == nil
  8.           return 0
  9.         elsif @terrain_tags[tile_id] > 0
  10.           return @terrain_tags[tile_id]
  11.         end
  12.       end
  13.     end
  14.     return 0
  15.   end
  16.  
  17. end
Expand to see the code.


Here's my attempt at fixing this:
  1. class Game_Map
  2.  
  3.   def terrain_tag(x, y)
  4.     if @map_id != 0
  5.       for i in [2, 1, 0]
  6.         tile_id = data[x, y, i]
  7.         if tile_id == nil
  8.           return 0
  9.         elsif @terrain_tags[tile_id] > 0
  10.           for event in $game_map.events.values
  11.             if event.x == x and event.y == y and event.through == false and event.tile_id != nil and @terrain_tags[event.tile_id] > 0
  12.               return @terrain_tags[event.tile_id]
  13.             end
  14.           end
  15.           return @terrain_tags[tile_id]
  16.         end
  17.       end
  18.     end
  19.     return 0
  20.   end
  21. end
Expand to see the code.
I really like this - a good idea with a simple solution!

You might consider throwing this in here?
Done :J

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=71202