BDR Tile Version: 1.2 for RMVX
By: Fustel
Introduction
How many times did you ask yourself: "What tile is the player on?".
One of the answer was to scan the $map.data layers and test all the values assignable for a single tile.
Another, the right one, is to use this little scripting tool that identify a tile by its panel ID ("A" to "E") and it column and row in the panel.
And... do I have to say this little one will soon be a requirement for future BDR scripts.
Features
Screenshots
Demo
Script
[rgss]#==============================================================================
# ** BDR Tile
#------------------------------------------------------------------------------
# © Fustel, 2010
# 13/04/10
# Version 1.2
#------------------------------------------------------------------------------
# VERSION HISTORY:
# - 1.0 (06/04/10), Initial release
# - 1.1 (13/04/10), the method is now 'tile_id' and callable from any Game_Map
# - 1.2 (19/04/10), introduction of the with_panel metod to the Array class
#-------------------------------------------------------------------------------
# INSTRUCTIONS:
# - Place this script in the 'Materials' section
# - Call tile_id( x, y, layer) from any map (generally $game_map)
# to get the id of the tile layer (1=ground, 2=decoration) at (x,y)
# - The result have a dual forms and may be seen as:
# - a 2 elements array (mainly designed for the ground layer):
# - the [0] element is the column in the tile panel
# - the [1] element is the row in the tile panel
# - a object with the following properties
# - 'pane' ("A" to "E") determining the panel
# - 'col' for the column in the panel
# - 'row' for the row in the panel
# - the 'with_panel' method of the object returns another objet wich
# can be seen as a 3 element array:
# - the [0] element is the column in the tile panel
# - the [1] element is the row in the tile panel
# - the [2] element is the panle ID ("A" to "E")
#------------------------------------------------------------------------------
# NOTES
# - The Array class has been modified so that the [0] and [1] elements can be
# refered by (respectively) 'col' and 'row' methods.
#==============================================================================
class Array
attr_accessor :panel
def col
return clone[ 0]
end
def row
return clone[ 1]
end
def with_panel
return [ col, row, @panel]
end
end
module RPG
class Map
def tile_id( x, y, layer=1)
result = []
begin
if layer == 1
m = [ @data[ x, y, 0], @data[ x, y, 1]].max
if ( 2048...8192).include?( m)
n = m-2048
n /= 48
result[ 0] = n % 8
result[ 1] = n / 8
elsif ( 1536...1664).include?( m)
n = m - 1536
result[ 0] = n % 8
result[ 1] = n / 8 + 16
end
result.panel = "A"
elsif layer == 2
m = @data[ x, y, 2]
case m / 256
when 0: result.panel = "B"
when 1: result.panel = "C"
when 2: result.panel = "D"
when 3: result.panel = "E"
end
m %= 256
result[ 0] = m % 8
result[ 1] = m / 8
end
rescue
end
return result
end
end
end
class Game_Map
def tile_id( x, y, layer=1)
return @map.tile_id( x, y, layer)
end
end
[/rgss]
Instructions
Exemples:
FAQ
Compatibility
No issue known, although the Array class was ovrloaded to include the 'col', 'row' and 'panel' attributes/methods
Credits and Thanks
All done by myself
Author's Notes
v1.0 to 1.1:
v1.1 to 1.2
Terms and Conditions
You may not use this in a commercial game without my explicit permission.
You may not post this script anywhere without my explict permission.
You must give me credit.
By: Fustel
Introduction
How many times did you ask yourself: "What tile is the player on?".
One of the answer was to scan the $map.data layers and test all the values assignable for a single tile.
Another, the right one, is to use this little scripting tool that identify a tile by its panel ID ("A" to "E") and it column and row in the panel.
And... do I have to say this little one will soon be a requirement for future BDR scripts.
Features
- Identifies tiles by panel, column and row in the panel
Screenshots
Demo
http://www.mediafire.com/file/utywztizjm2/BDR Tile - v1.2.zip
Just walk around and use the 'Analyze Map Tile" skill to see what's under your feet (or above your head).
All is in the script line of the commopn event 'Show Map Tile'.
Just walk around and use the 'Analyze Map Tile" skill to see what's under your feet (or above your head).
All is in the script line of the commopn event 'Show Map Tile'.
Script
[rgss]#==============================================================================
# ** BDR Tile
#------------------------------------------------------------------------------
# © Fustel, 2010
# 13/04/10
# Version 1.2
#------------------------------------------------------------------------------
# VERSION HISTORY:
# - 1.0 (06/04/10), Initial release
# - 1.1 (13/04/10), the method is now 'tile_id' and callable from any Game_Map
# - 1.2 (19/04/10), introduction of the with_panel metod to the Array class
#-------------------------------------------------------------------------------
# INSTRUCTIONS:
# - Place this script in the 'Materials' section
# - Call tile_id( x, y, layer) from any map (generally $game_map)
# to get the id of the tile layer (1=ground, 2=decoration) at (x,y)
# - The result have a dual forms and may be seen as:
# - a 2 elements array (mainly designed for the ground layer):
# - the [0] element is the column in the tile panel
# - the [1] element is the row in the tile panel
# - a object with the following properties
# - 'pane' ("A" to "E") determining the panel
# - 'col' for the column in the panel
# - 'row' for the row in the panel
# - the 'with_panel' method of the object returns another objet wich
# can be seen as a 3 element array:
# - the [0] element is the column in the tile panel
# - the [1] element is the row in the tile panel
# - the [2] element is the panle ID ("A" to "E")
#------------------------------------------------------------------------------
# NOTES
# - The Array class has been modified so that the [0] and [1] elements can be
# refered by (respectively) 'col' and 'row' methods.
#==============================================================================
class Array
attr_accessor :panel
def col
return clone[ 0]
end
def row
return clone[ 1]
end
def with_panel
return [ col, row, @panel]
end
end
module RPG
class Map
def tile_id( x, y, layer=1)
result = []
begin
if layer == 1
m = [ @data[ x, y, 0], @data[ x, y, 1]].max
if ( 2048...8192).include?( m)
n = m-2048
n /= 48
result[ 0] = n % 8
result[ 1] = n / 8
elsif ( 1536...1664).include?( m)
n = m - 1536
result[ 0] = n % 8
result[ 1] = n / 8 + 16
end
result.panel = "A"
elsif layer == 2
m = @data[ x, y, 2]
case m / 256
when 0: result.panel = "B"
when 1: result.panel = "C"
when 2: result.panel = "D"
when 3: result.panel = "E"
end
m %= 256
result[ 0] = m % 8
result[ 1] = m / 8
end
rescue
end
return result
end
end
end
class Game_Map
def tile_id( x, y, layer=1)
return @map.tile_id( x, y, layer)
end
end
[/rgss]
Instructions
- Copy the script in the 'Materials' section, as it fully overwrite the main methods
- Call the tile_id(x,y,layer) method from any map (be it a RPG::Map or a Game_Map instance), where
- 'x' & 'y' are the coordinates of the tile in the current map needing identification
- 'layer' is optional and is the layer needing identification (1 for ground (default), 2 for decorative)
- The result have a dual forms and may be seen as:
- a 2 elements array (mainly designed for the ground layer):
- the [0] element is the column in the tile panel
- the [1] element is the row in the tile panel
- a object with the following properties
- 'panel' ("A" to "E") determining the panel
- 'col' for the column in the panel
- 'row' for the row in the panel
- a 2 elements array (mainly designed for the ground layer):
- The 'with_panel' method of the resulting object returns the same object, except its Array view is as follow:
- the [0] element is the column in the tile panel
- the [1] element is the row in the tile panel
- the [2] element is the panel ID ("A" to "E")
Exemples:
- id = $game_map.tile_id( $gamep_player.x, $game_player.y) # => [ 0, 2] on grass
- id = $game_map.tile_id( $gamep_player.x, $game_player.y, 2).with_panel # => [ 0, 30, "D"] on a rail track
FAQ
Compatibility
No issue known, although the Array class was ovrloaded to include the 'col', 'row' and 'panel' attributes/methods
Credits and Thanks
All done by myself
Author's Notes
v1.0 to 1.1:
- The method to call is renamed 'tile_id'
- The method is to be called from a map, not the BDR::Tile modul, which is removed
v1.1 to 1.2
- Adds the 'with_panel' method to the ID object
Terms and Conditions
You may not use this in a commercial game without my explicit permission.
You may not post this script anywhere without my explict permission.
You must give me credit.