Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

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:
Code:
class Game_Map

 

  def terrain_tag(x, y)

    if @map_id != 0

      for i in [2, 1, 0]

        tile_id = data[x, y, i]

        if tile_id == nil

          return 0

        elsif @terrain_tags[tile_id] > 0

          return @terrain_tags[tile_id]

        end

      end

    end

    return 0

  end

 

end

Here's my attempt at fixing this:
Code:
class Game_Map

 

  def terrain_tag(x, y)

    if @map_id != 0

      for i in [2, 1, 0]

        tile_id = data[x, y, i]

        if tile_id == nil

          return 0

        elsif @terrain_tags[tile_id] > 0

          for event in $game_map.events.values

            if event.x == x and event.y == y and event.through == false and event.tile_id != nil and @terrain_tags[event.tile_id] > 0

              return @terrain_tags[event.tile_id]

            end

          end

          return @terrain_tags[tile_id]

        end

      end

    end

    return 0

  end

end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top