05-16-2024, 05:15 AM
(This post was last modified: 05-16-2024, 05:16 AM by DerVVulfman.)
I've been thinking about RPG Editors... Its always the map that confuses people when it comes to making an editor. Well, the map is saved in the very same converted text format (rxdata, rvdata... whatever) as the rest of the game data in the ruby editions of RPGMaker.
I decided to post a little script here that is my examination of the map data:
This stupid little script executes merely by running a script call of "do_it". It will read the MapInfos file and the first map in my project. It wasn't really for content like the map name or tile ID, but for examining the data structure for the rendered map and the structure of MapInfos itself.
So far, the only real issue happens when you switch the actual tileset in use, either loading/replacing a tileset or switching from one map to another ... and thereby changing the tileset in memory. I think the editor must (1) clear all autotile graphic data, and then (2) recombine the individual 'chunks' that get drawn which are seen when you 'double-click' any single autotile in the editor.
I would so love to see someone use this knowledge to make an actual map editor.
I decided to post a little script here that is my examination of the map data:
Code:
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
# This interpreter runs event commands. This class is used within the
# Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# * DO IT
#--------------------------------------------------------------------------
def do_it
# Get the MapInfos list (most... if not all... content is for the editor)
map_list = load_data("Data/MapInfos.rxdata")
# Process the Map Infos list
map_list(map_list)
# Get the data from a map
map_data = load_data("Data/Map001.rxdata")
# Display the data
the_general(map_data)
# Perform TABLE data exam method
the_table(map_data.data)
# Perform TABLE data exam method
the_events(map_data.events)
# Perform TABLE data exam method
the_encounters(map_data.encounter_list)
end
#--------------------------------------------------------------------------
# * Get data from MapInfos itself
#--------------------------------------------------------------------------
def map_list(data)
# Get the 'Keys' to the MapInfos Hash array.
# Each key is the ID of a map, and is ALSO the 'filename' of the
# map in the data folder once formatted. Ex: #4 = Map004.rxdata
#
keys = data.keys
p keys
# Just get the first key in the keys array
key = keys[0]
# Get a map (the 1st) and render it
a_map = data[key]
p a_map
# Data for a given map in the MapInfos Hash:
#
p a_map.name # the name given to the map (just like in map data)
p a_map.parent_id # If a child map, the ID/key of the parent map
p a_map.order # Presentation order in the list (even if spoilered)
p a_map.expanded # If spoilered or not
p a_map.scroll_x # The editor's x-axis scrollbar position
p a_map.scroll_y # The editor's y-axis scrollbar position
end
#--------------------------------------------------------------------------
# * Deal with the data
#--------------------------------------------------------------------------
def the_general(data)
# Nice little title to pop up
p "MAP DATA"
# Hey, let's get a breakdown of the data for a map
#
p data.bgm # Audio Class
p data.events # ARRAY
p data.tileset_id # ... the tileset id
p data.bgs # Audio Class
p data.autoplay_bgs # True/False flag
p data.height # Dimensions: Height
p data.width # Dimensions: Width
p data.data # MAP DATA TABLE
p data.encounter_step # No of steps before an encounter
p data.encounter_list # ARRAY
end
#--------------------------------------------------------------------------
# * Deal with the map table
#--------------------------------------------------------------------------
def the_table(data)
# Nice little title to pop up
p "MAP"
# Print Map dimensions (horizontal, vertical and layers)
#
p "Map Dimensions are..."
p data.xsize # How wide in tiles
p data.ysize # How tall in tiles
p data.zsize # How many layers is it?
# Sort throught all horizontal tiles on top most 0 horizontal and layer 0
#
# The data is a 'table', so we are talking a table with three dimensions:
# X, Y, Z. So data[4,3,1] would be X,Y of 4,3 on layer 1. This assuming
# that we start on coordinate 0,0 and not 1,1.
#
p "Let's get the top row, shall we?"
for x in 0...data.xsize
tile = data[x, 0, 0]
p tile
end
# Each Autotile is comprised of 48 smaller pieces, the Editor displaying
# the segments in an 8x6 display
# There are 8 autotiles (including the fixed "EMPTY" tile.
# Thus 8 autotiles of 48 pieces comprise the first 384 tiles as suggested
# in Sprite_Character
# Just show the layer count...
#
p 'Layer Count'
for layer in 0...data.zsize
p layer
end
# NOTES: Any tile value of 0 is an empty spot.
#
# Tiles 1-384 are autotiles, each individual tile is broken
# into 48 segments. These can be seen by double-clicking the
# autotile in the tile selection window.
#
# There are 8 autotiles (including the fixed "EMPTY" tile.
# Thus 8 autotiles of 48 pieces comprise the first 384 tiles
# as suggested in Sprite_Character
#
# And any tile above 384 is a static tile.
end
#--------------------------------------------------------------------------
# * Deal with the map table
#--------------------------------------------------------------------------
def the_events(data)
# Nice little title to pop up
p 'EVENT'
# Get the 'Keys' to the event Hash array.
# Each key is the ID of an event (starting from 1 on up).
keys = data.keys
p keys
# THE ACTUAL EVENT
event = data[1]
# Data in the event:
p event.id
p event.name
p event.x
p event.y
p event.pages # RPG::Event::Pages
# Breakdown the pages of an event
the_event_pages(event.pages)
end
#--------------------------------------------------------------------------
# * Breakdown of the event's pages
#--------------------------------------------------------------------------
def the_event_pages(pages)
# How many pages in the event
p pages.size
# Get a single page:
page = pages[0]
# Get the STUFF in a single page
p page.condition # RPG::Event::Page::Condition
p page.graphic # RPG::Event::Page::Graphic
p page.move_type
p page.move_speed
p page.move_frequency
p page.move_route # Your RPG::MoveRoute
p page.walk_anime
p page.step_anime
p page.direction_fix
p page.through
p page.always on top
p page.trigger
p page.list # The RPG::EventCommand array
end
#--------------------------------------------------------------------------
# * Deal with the map table
#--------------------------------------------------------------------------
def the_encounters(data)
# Just an array of the Troop IDs that are attached...
# ... If you have random encounters.
#
p data
end
end
This stupid little script executes merely by running a script call of "do_it". It will read the MapInfos file and the first map in my project. It wasn't really for content like the map name or tile ID, but for examining the data structure for the rendered map and the structure of MapInfos itself.
So far, the only real issue happens when you switch the actual tileset in use, either loading/replacing a tileset or switching from one map to another ... and thereby changing the tileset in memory. I think the editor must (1) clear all autotile graphic data, and then (2) recombine the individual 'chunks' that get drawn which are seen when you 'double-click' any single autotile in the editor.
I would so love to see someone use this knowledge to make an actual map editor.