module ReadMaprvdata
@map_infos = load_data('Data/MapInfos.rvdata')
def self.write(map_id)
map = load_data(sprintf("Data/Map%03d.rvdata", map_id))
f = File.new(sprintf("Data/Map%03d.text", map_id), 'w')
f.write("#{sprintf("Map%03d", map_id)}: #{@map_infos[map_id].name}\n")
@indent = 0
map.instance_variables.sort.each do |iv|
self.write_object(iv, map.instance_variable_get(iv), f)
@indent -= 1
end
f.close
end
private
def self.write_object(iv, g_iv, f)
f.write("#{' ' * @indent}#{iv.sub(/@/, '')}: #{g_iv}\n")
@indent += 1
if g_iv.is_a?(Hash)
g_iv.each do |key, value|
self.write_object("@#{key}", value, f)
@indent -= 1
end
elsif g_iv.is_a?(Array)
g_iv.each do |value|
self.write_object("@#{g_iv.index(value)}", value, f)
@indent -= 1
end
else
g_iv.instance_variables.sort.each do |iv2|
self.write_object(iv2, g_iv.instance_variable_get(iv2), f)
@indent -= 1
end
end
end
end