Kingdom Ablaze
Sponsor
ok so ive been working on my interactive map script. and ive been trying really hard to get the game to properly store and recover my map data so i can make a simple editor so people who cant script can use the mouse to make thier map. anyways here is what the data currently looks like
Map_Items::Town.new(80,130,1,8,4,2,"town3","Saar",1)
and here is my data structure if u need it
ive managed to get the game to store the data into a rxdata file, and when i open it in notepad it looks right. but i cant seem to get the data back out properly. so i was wondering if some one could show me a simple example of storeing data and recovering it.
p.s. btw the reason im asking for rxdata is so people can copy and paste from editor to game with no issues
p.s.s. its really late sorry if i forgot anything you need to know
Map_Items::Town.new(80,130,1,8,4,2,"town3","Saar",1)
and here is my data structure if u need it
Code:
#==============================================================================
# ** Data::Object, Map_Items::Town, Sub::Town
#------------------------------------------------------------------------------
# These classes were created by SephirothSpawn
#==============================================================================
module Map_Items
Towns = {}
end
module Sub
Towns = {}
end
class Data::Object
@@ids = {}
@@containers = {}
attr_accessor :id
def initialize
@@ids[self.class] = 0 unless @@ids.has_key?(self.class)
@@ids[self.class] += 1
@id = @@ids[self.class]
if @@containers.has_key?(self.class)
@@containers[self.class][@id] = self
end
end
def self.add_container(class_name, container)
@@containers[class_name] = container
end
end
class Map_Items::Town < Data::Object
Data::Object.add_container(self, Map_Items::Towns)
attr_reader :screen_x
attr_reader :screen_y
attr_reader :map_id
attr_reader :map_x
attr_reader :map_y
attr_reader :direction
attr_reader :icon
attr_reader :town_name
attr_reader :switch
def initialize(screen_x, screen_y, map_id, map_x, map_y, direction, icon, town_name, switch)
super()
@screen_x = screen_x
@screen_y = screen_y
@map_id = map_id
@map_x = map_x
@map_y = map_y
@direction = direction
@icon = icon
@town_name = town_name
@switch = switch
end
end
class Sub::Town < Data::Object
Data::Object.add_container(self, Sub::Towns)
attr_reader :screen_x
attr_reader :screen_y
attr_reader :map_id
attr_reader :map_x
attr_reader :map_y
attr_reader :direction
attr_reader :icon
attr_reader :town_name
attr_reader :switch
attr_reader :upper_level
def initialize(screen_x, screen_y, map_id, map_x, map_y, direction, icon, town_name, switch, upper_level)
super()
@screen_x = screen_x
@screen_y = screen_y
@map_id = map_id
@map_x = map_x
@map_y = map_y
@direction = direction
@icon = icon
@town_name = town_name
@switch = switch
@upper_level = upper_level
end
end
#==============================================================================
# ** Sprite_Cursor
#------------------------------------------------------------------------------
# This sprite is used to display the cursor for World_Map.
#==============================================================================
class Sprite_Cursor < Sprite
def initialize(viewport = Viewport.new(0, 0, 0, 0))
super(viewport)
update
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
end
end
#==============================================================================
# ** Window_Map
#------------------------------------------------------------------------------
# This window displays the name box for World_Map
#==============================================================================
class Window_Map < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.z = 2010
@text = ""
end
def text=(text)
if @text != text
@text = text
self.contents.clear
self.contents.draw_text(0, 0, contents.width, 32, @text, 1)
end
end
end
ive managed to get the game to store the data into a rxdata file, and when i open it in notepad it looks right. but i cant seem to get the data back out properly. so i was wondering if some one could show me a simple example of storeing data and recovering it.
p.s. btw the reason im asking for rxdata is so people can copy and paste from editor to game with no issues
p.s.s. its really late sorry if i forgot anything you need to know