More terrain tags

This script lets you have more terrains for each map making that each map or
tileset use a unique palette of terrain tags.
It also add support for using codes and not numbers for scripters.

  1. #=============================================================================
  2. # More terrain tags
  3. # By gerkrt/gerrtunk
  4. # Version: 1
  5. # Date: 09/09/2011
  6. # IMPORTANT NOTE: to acces the more actualitzed or corrected version of this
  7. # script check here: http://usuarios.multimania.es/kisap/english_list.html
  8. # License: GPL, credits
  9. #==============================================================================
  10. =begin
  11.  
  12. ------INTRODUCTION------
  13.  
  14. This script lets you have more terrains for each map making that each map or
  15. tileset use a unique palette of terrain tags.  
  16. It also add support for using codes and not numbers for scripters.
  17.  
  18. ------MAP OR TILESET MODE------
  19.  
  20. This script can work in two ways: based on maps or in tilesets. If there
  21. are a palette for all maps using a tileset and for that tileset, or if
  22. exist a palette for each map.
  23.  
  24. The sense of the config number => changues with the mode you are using.
  25.  
  26. To use the tileset mode active this line:
  27. Terrain_tileset_mode = true
  28.  
  29. You have to add new lines for each map or tileset
  30.   Maps_indexs = {
  31.     4 => [99,1,2,3,4,5,6,7],
  32.     2 => [8,9,10,11,12,13,14,15],
  33.     9 => [8,9,10,11,12,13,14,15]
  34.   }
  35.  
  36. id de terr/map => [terr1, terr2, terr...]
  37.  
  38. Note that if you dont put a map or tileset here, it will use default ones(0-7)
  39.  
  40. ------CODES------
  41.  
  42. You can use :codes for improving visual use of the tags. For this you need
  43. set default codes, descoment the line and comnt the other set to false.
  44.  
  45. =end
  46.  
  47. module Wep
  48.   Maps_indexs = {
  49.     4 => [99,1,2,3,4,5,6,7],
  50.     2 => [8,9,10,11,12,13,14,15]
  51.   }
  52.  
  53.   #Default_codes = [:op, :wep, :nor, :ir, :lar, :set, :rat, :iku]
  54.   Terrain_tileset_mode = false
  55.   Default_codes = false
  56. end
  57.  
  58.  
  59. class Game_Map
  60.  
  61.   #--------------------------------------------------------------------------
  62.   # * Get Terrain Tag
  63.   #     x          : x-coordinate
  64.   #     y          : y-coordinate
  65.   #--------------------------------------------------------------------------
  66.   def terrain_tag(x, y)
  67.  
  68.     if @map_id != 0
  69.       for i in [2, 1, 0]
  70.         tile_id = data[x, y, i]
  71.         if tile_id == nil
  72.           return 0
  73.         else
  74.           # If by terrain
  75.           if Wep::Terrain_tileset_mode
  76.             if Wep::Maps_indexs[@map.tileset_id] != nil
  77.               return Wep::Maps_indexs[@map.tileset_id][@terrain_tags[tile_id]]
  78.             else
  79.               if Wep::Default_codes
  80.                 return Wep::Default_codes[@terrain_tags[tile_id]]
  81.               else
  82.                 return @terrain_tags[tile_id]
  83.               end
  84.             end
  85.            
  86.           # By map
  87.           else
  88.             if Wep::Maps_indexs[@map_id] != nil
  89.               return Wep::Maps_indexs[@map_id][@terrain_tags[tile_id]]
  90.             else
  91.               if Wep::Default_codes
  92.                 return Wep::Default_codes[@terrain_tags[tile_id]]
  93.               else
  94.                 return @terrain_tags[tile_id]
  95.               end
  96.             end
  97.           end  
  98.         end
  99.       end
  100.     end
  101.  
  102.   end
  103.  
  104.  
  105. end
Expand to see the code.
This would be the most amazing script ever. . . but I cant make heads or tails of it. . . sorry :\
Perhaps an example?
With the default ones, you can use terrain tags from 0 to 7. These tags ids are the same for all the maps.

With my script each map have his own terrain tags, giving a translation from the orignal code (0-7 also, that cant be changued because of the closed editor) to a new number or code, so, you can create more terrain tags to use, but with the limitation of 8 per map(or by tileset, exist two modes).
Maps_indexs = {
4 => [99,1,2,3,4,5,6,7],
2 => [8,9,10,11,12,13,14,15],
}


This means that for map 4 the tag id1 in the map editor is 99, and the rest work like the same.
But for the 2, the 0 is 8, the 1 is 9, the 2 is 10...etc.

So, if you use a event comand get terrain tag of the player, and its in map 2 and the terrain tag of the tile is 2, it will return the number 10 and not 2, so you can use more tags.

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