 |
【导出结果】 //这些代码是系统自动生成的,请不要修改这些代码 package RXData { public dynamic class MapInfo { public function MapInfo() { this[5] = {}; // RPG::MapInfo this[5].scroll_x = 320; this[5].name = "*1, 2"; this[5].expanded = false; this[5].order = 4; this[5].scroll_y = 240; this[5].parent_id = 2; this[6] = {}; // RPG::MapInfo this[6].scroll_x = 320; this[6].name = "*1, 3"; this[6].expanded = false; this[6].order = 5; this[6].scroll_y = 240; this[6].parent_id = 2; this[1] = {}; // RPG::MapInfo this[1].scroll_x = 320; this[1].name = "开始地图"; this[1].expanded = false; this[1].order = 1; this[1].scroll_y = 240; this[1].parent_id = 0; this[7] = {}; // RPG::MapInfo this[7].scroll_x = 320; this[7].name = "*1, -1"; this[7].expanded = false; this[7].order = 6; this[7].scroll_y = 240; this[7].parent_id = 2; this[8] = {}; // RPG::MapInfo this[8].scroll_x = 320; this[8].name = "*1, -2"; this[8].expanded = false; this[8].order = 7; this[8].scroll_y = 240; this[8].parent_id = 2; this[4] = {}; // RPG::MapInfo this[4].scroll_x = 320; this[4].name = "*1, 1"; this[4].expanded = false; this[4].order = 3; this[4].scroll_y = 240; this[4].parent_id = 2; } } }
|
 |
【Ruby脚本】 class Object def getLiteral if (self.is_a?(String)) str = self.clone str.removeBeginning("@") str.addQuotes return str end end end
#============================================================================== # ■ String+ #------------------------------------------------------------------------------ # 处理字符串的附加方法类。 #==============================================================================
class String def addSlashes end def addQuotes self.addSlashes self.insert(0, "\"") self.concat("\"") end def beginsWith(str) strlen = str.length if self.length < strlen return false end if self[0, strlen] == str return true else return false end end def removeBeginning(str) self[0, str.length] = '' if self.beginsWith(str) end def trim return if (self.empty?) while self[0, 1] == " " or self[0, 1] == "\t" self[0, 1] = "" end while self[-1, 1] == " " self[-1, 1] = "" end end end
#============================================================================== # ■ Exporter #------------------------------------------------------------------------------ # 处理RMXP数据导出的类。 #==============================================================================
class Exporter #-------------------------------------------------------------------------- # ● 常量 #-------------------------------------------------------------------------- AS_FOLDER = "../FlashProject/RXData/" #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_accessor :data attr_reader :rxdataFile attr_reader :as3File attr_reader :clsName attr_reader :file #-------------------------------------------------------------------------- # ● 初始化对像 # rxdataFile : rxdata文件名 #-------------------------------------------------------------------------- def initialize(rxdataFileName) @clsName = rxdataFileName @clsName = "MapInfo" if (rxdataFileName == "MapInfos") @rxdataFile = "data/" + rxdataFileName + ".rxdata" @as3File = AS_FOLDER + @clsName + ".as" @data = load_data(@rxdataFile) @variables = [] end #-------------------------------------------------------------------------- # ● 导出到AS文件 #-------------------------------------------------------------------------- def export @file = File.open(@as3File, "w") @file.write("//这些代码是系统自动生成的,请不要修改这些代码\n") @file.write("package RXData {\n") @file.write("\tpublic dynamic class #{@clsName} {\n") @file.write("\t\tpublic function #{@clsName}() {\n") exportObj(@data, "\t\t\tthis") @file.write("\t\t}\n\t}\n}") @file.close() end #-------------------------------------------------------------------------- # ● 导出数组或对象 #-------------------------------------------------------------------------- def exportObj(obj, scrStart) head = scrStart.clone head.trim if obj.is_a?(Hash) @file.write("#{scrStart} = {};\n") if (head != "this") keys = obj.keys for keyName in keys exportObj(obj[keyName], "#{scrStart}[#{keyName}]") end elsif obj.is_a?(Numeric) value = obj.to_s @file.write("#{scrStart} = #{value};\n") elsif obj.is_a?(String) obj.addQuotes @file.write("#{scrStart} = #{obj};\n") elsif obj.is_a?(TrueClass) or obj.is_a?(FalseClass) value = obj.to_s @file.write("#{scrStart} = #{value};\n") else # is an object with attributes to be exported type = obj.type @file.write("#{scrStart} = {}; // #{type}\n") if (head != "this") vars = obj.instance_variables for varName in vars propName = varName.clone propName.removeBeginning("@") exportObj(obj.instance_variable_get(varName), "#{scrStart}.#{propName}") end end end end
#============================================================================== # ** Main #------------------------------------------------------------------------------ # This script is written by Octopus. #==============================================================================
exporter = Exporter.new("MapInfos") for keyName in exporter.data.keys # 删除地图名以#开头的地图 exporter.data.delete(keyName) if exporter.data[keyName].name.beginsWith("#") end exporter.export()
|
 |
System.rxdata的数据也能导出了! 恭喜!
|
 |
//这些代码是系统自动生成的,请不要修改这些代码 package RXData { public dynamic class Actors { public function Actors() { this[1] = {}; // RPG::Actor this[1].initial_level = 1; this[1].armor4_id = 0; this[1].weapon_id = 1; this[1].character_name = "001-Fighter01"; this[1].name = "勇士"; this[1].exp_inflation = 35; this[1].parameters = {}; // Table this[1].armor2_fix = false; this[1].class_id = 1; this[1].armor3_id = 13; this[1].armor1_fix = false; this[1].exp_basis = 25; this[1].armor2_id = 5; this[1].battler_hue = 0; this[1].armor4_fix = false; this[1].final_level = 99; this[1].weapon_fix = false; this[1].armor1_id = 1; this[1].id = 1; this[1].character_hue = 0; this[1].battler_name = "001-Fighter01"; this[1].armor3_fix = false; } } } Actors也能了
|
 |
导出完毕! 
|