Advertisement
nathmatt

Unlimited Terrain Tags Version 1.0

Jul 13th, 2011
706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.72 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # Unlimited Terrain Tags Script by Nathmatt
  3. # Version: 1.00
  4. # Type: Add On
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  6. #  
  7. #  This work is protected by the following license:
  8. # #----------------------------------------------------------------------------
  9. # #  
  10. # #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
  11. # #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
  12. # #  
  13. # #  You are free:
  14. # #  
  15. # #  to Share - to copy, distribute and transmit the work
  16. # #  to Remix - to adapt the work
  17. # #  
  18. # #  Under the following conditions:
  19. # #  
  20. # #  Attribution. You must attribute the work in the manner specified by the
  21. # #  author or licensor (but not in any way that suggests that they endorse you
  22. # #  or your use of the work).
  23. # #  
  24. # #  Noncommercial. You may not use this work for commercial purposes.
  25. # #  
  26. # #  Share alike. If you alter, transform, or build upon this work, you may
  27. # #  distribute the resulting work only under the same or similar license to
  28. # #  this one.
  29. # #  
  30. # #  - For any reuse or distribution, you must make clear to others the license
  31. # #    terms of this work. The best way to do this is with a link to this web
  32. # #    page.
  33. # #  
  34. # #  - Any of the above conditions can be waived if you get permission from the
  35. # #    copyright holder.
  36. # #  
  37. # #  - Nothing in this license impairs or restricts the author's moral rights.
  38. # #  
  39. # #----------------------------------------------------------------------------
  40. #
  41. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  42. # Instrutions:
  43. #  Scroll down to the config and add terrain_tags by adding these to the config
  44. #  module (Unlimited_Terrain_Tags.add_terrains(tileset_id,x,y,terrain_tag))
  45. #
  46. #   tileset_id  - is the tilsets id
  47. #   x,y         - is the location on the tile set
  48. #   terrain_tag - is the terrain_tag for that tile
  49. #
  50. # To get the x and y think of the tilset as the map and the x and y are each block
  51. # dont count the auto tiles.
  52. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  53. module Unlimited_Terrain_Tags
  54.  
  55. # dont touch any of this
  56.  
  57.   $terrains = []
  58.  
  59.   class Terrains
  60.    
  61.     attr_reader   :tileset_id,:tile_id,:terrain_tag
  62.    
  63.     def initialize(tileset_id,tile_id,terrain_tag)
  64.       @tileset_id,@tile_id,@terrain_tag = tileset_id,tile_id,terrain_tag
  65.     end
  66.    
  67.   end
  68.  
  69.   def self.get_tile_id(x,y)
  70.     return((y*8)+x)+384
  71.   end
  72.  
  73.   def self.add_terrains(tileset_id,x,y,terrain_tag)
  74.     $terrains.push(Terrains.new(tileset_id,self.get_tile_id(x,y),terrain_tag))
  75.   end  
  76.  
  77.   #============================================================================
  78.   # MCES::Config
  79.   #----------------------------------------------------------------------------
  80.   #  The configuration for Unlimited Terrain Tags
  81.   #============================================================================
  82.   module Config
  83.     # add terrain tags here
  84.     #Unlimited_Terrain_Tags.add_terrains(tileset_id,x,y,terrain_tag)
  85.   end
  86.  
  87.   def self.get_terrain_tag(tileset_id,tile_id)
  88.     $terrains.each {|terrain|
  89.     if [tileset_id,tile_id] == [terrain.tileset_id,terrain.tile_id]
  90.       return terrain.terrain_tag
  91.     end}
  92.     return 0
  93.   end
  94.  
  95. end
  96.  
  97. class Game_Map
  98.  
  99.   def terrain_tag(x, y)
  100.     if @map_id != 0
  101.       [2, 1, 0].each{|i|
  102.       tile_id = data[x, y, i]
  103.       if tile_id == nil
  104.         return 0
  105.       else
  106.         t = Unlimited_Terrain_Tags.get_terrain_tag(@map.tileset_id,tile_id)
  107.         return t if t > 0
  108.         return @terrain_tags[tile_id] if @terrain_tags[tile_id] > 0
  109.       end}
  110.     end
  111.     return 0
  112.   end
  113.  
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement