目前共有8篇帖子。 內容轉換:不轉換▼
 
點擊 回復
544 7
【备份】2013年3月发布的Flash样板的Ruby脚本备份
一派護法 十九級
1樓 發表于:2015-12-6 10:47
$game_scripts=[]
def trim(str)
  return str if (str.empty?)
 
  while str[0,1]==" " or str[0,1]=="\t"
      str[0,1]=""
  end
  while str[-1,1]==" "
    str[-1,1]=""
  end
  return str
end
一派護法 十九級
2樓 發表于:2015-12-6 10:47
【解压系统数据】
system=load_data("Data/System.rxdata")
file=File.open("../RXData/System.as","w")
file.write("//这些代码是系统自动生成的,请不要修改这些代码\n")
file.write("\n")
file.write("package RXData\n")
file.write("{\n")
file.write("    public class System\n")
file.write("    {\n")
file.write("        public var switches_num:int="+\
  (system.switches.length-1).to_s+"; //开关数\n")
file.write("        public var variables_num:int="+\
  (system.variables.length-1).to_s+"; //变量数\n")
file.write("        public function System()\n")
file.write("        {\n")
file.write("        }\n")
file.write("    }\n")
file.write("}")
file.close()
一派護法 十九級
3樓 發表于:2015-12-6 10:47
【解压地图和事件】
map_infos=load_data("Data/MapInfos.rxdata")
map_num=map_infos.size # 地图总数

file=File.open("../RXData/MapInfos.as","w")
file.write("//这些代码是系统自动生成的,请不要修改这些代码\n")
file.write(\
  "//获取地图图块的方法:game.maps.map[地图id].data[第几层][x坐标][y坐标]\n")
file.write("\n")
file.write("package RXData\n")
file.write("{\n")
file.write("    public class MapInfos\n")
file.write("    {\n")
file.write("        public var num:int="+map_num.to_s+"; //地图总数\n")
file.write("        public var start_pos:Object={map_id:"+system.start_map_id.to_s)
file.write(",x:"+system.start_x.to_s+",y:"+system.start_y.to_s+"}")
file.write("; //角色开始位置\n")
file.write("        public var map:Array=new Array();\n")
file.write("        public function MapInfos()\n");
file.write("        {\n");

# 遍历所有地图
for map_id in 1..map_num
  map_file_name=sprintf("Data/Map%03d.rxdata",map_id)
  map=load_data(map_file_name) # 打开地图文件
 
  # 输出地图信息
  file.write("\t\t\tmap["+map_id.to_s+"]=new Object();\n")
  file.write("\t\t\tmap["+map_id.to_s+"].name=\""+\
    map_infos[map_id].name+"\";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].parent_id="+map_infos[map_id].\
    parent_id.to_s+";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].order="+map_infos[map_id].\
    order.to_s+";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].expanded="+map_infos[map_id].\
    expanded.to_s+";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].scroll=["+map_infos[map_id].\
    scroll_x.to_s+","+map_infos[map_id].scroll_y.to_s+"];\n")
   
  file.write("\t\t\tmap["+map_id.to_s+"].tileset_id="+map.tileset_id.\
    to_s+";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].width="+map.width.to_s+";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].height="+map.height.to_s+";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].autoplay_bgm="+map.autoplay_bgm.\
    to_s+";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].autoplay_bgs="+map.autoplay_bgs.\
    to_s+";\n")
 
  #BGM
  file.write("\t\t\tmap["+map_id.to_s+"].bgm=new Object();\n")
  file.write("\t\t\tmap["+map_id.to_s+"].bgm.name=\""+map.bgm.name+"\";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].bgm.volume="+map.bgm.\
    volume.to_s+";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].bgm.pitch="+map.bgm.\
    pitch.to_s+";\n")
  #BGS
  file.write("\t\t\tmap["+map_id.to_s+"].bgs=new Object();\n")
  file.write("\t\t\tmap["+map_id.to_s+"].bgs.name=\""+map.bgs.name+"\";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].bgs.volume="+map.bgs.\
    volume.to_s+";\n")
  file.write("\t\t\tmap["+map_id.to_s+"].bgs.pitch="+map.bgs.\
    pitch.to_s+";\n")
 
  file.write("\t\t\tmap["+map_id.to_s+"].encounter_list=["+map.\
    encounter_list.join(",")+"];\n") # 遇敌目录。为队伍 ID 的数组。
  file.write("\t\t\tmap["+map_id.to_s+"].encounter_step="+map.\
    encounter_step.to_s+";\n") # 遇敌步数
 
  file.write("\t\t\tmap["+map_id.to_s+"].data=new Array();\n")
  for i in 0..2
    file.write("\t\t\tmap["+map_id.to_s+"].data["+i.to_s+"]=[")
    for y in 0..map.height-1
      for x in 0..map.width-1
        file.write(map.data[x,y,i].to_s)
        file.write(",") unless (x==map.width-1 and y==map.height-1)
      end
      #file.write(" ")
    end
    file.write("];\n")
  end
 
  # 输出事件
  s="\t\t\tmap["+map_id.to_s+"].events";
  file.write(s+"=new Array();\n")
  for i in 1..map.events.length
    s2=s+"["+i.to_s+"]";
    file.write(s2+"=new Object();\n")
    e=map.events[i];
    file.write(s2+".id="+e.id.to_s+";\n")
    file.write(s2+".name=\""+e.name+"\";\n")
    file.write(s2+".x="+e.x.to_s+";\n") # 位置
    file.write(s2+".y="+e.y.to_s+";\n")
    file.write(s2+".pages=new Array();\n")
   
    for j in 0..e.pages.length-1
      s3=s2+".pages["+j.to_s+"]"
      p=e.pages[j]
      file.write(s3+"=new Object();\n")
     
      # 条件
      file.write(s3+".condition=new Object();\n")
      file.write(s3+".condition.switch1_valid="+p.condition.\
        switch1_valid.to_s+";\n")
      file.write(s3+".condition.switch2_valid="+p.condition.\
        switch2_valid.to_s+";\n")
      file.write(s3+".condition.variable_valid="+p.condition.\
        variable_valid.to_s+";\n")
      file.write(s3+".condition.self_switch_valid="+p.condition.\
        self_switch_valid.to_s+";\n")
      file.write(s3+".condition.switch1_id="+p.condition.\
        switch1_id.to_s+";\n")
      file.write(s3+".condition.switch2_id="+p.condition.\
        switch2_id.to_s+";\n")
      file.write(s3+".condition.variable_id="+p.condition.\
        variable_id.to_s+";\n")
      file.write(s3+".condition.variable_value="+p.condition.\
        variable_value.to_s+";\n")
      file.write(s3+".condition.self_switch_ch=\""+p.condition.\
        self_switch_ch+"\";\n")
     
      # 图像
      file.write(s3+".graphic=new Object();\n")
      file.write(s3+".graphic.tile_id="+p.graphic.tile_id.to_s+";\n")
      file.write(s3+".graphic.character_name=\""+p.graphic.\
        character_name+"\";\n")
      file.write(s3+".graphic.character_hue="+p.graphic.\
        character_hue.to_s+";\n")
      file.write(s3+".graphic.direction="+p.graphic.\
        direction.to_s+";\n")
      file.write(s3+".graphic.pattern="+p.graphic.\
        pattern.to_s+";\n")
      file.write(s3+".graphic.opacity="+p.graphic.\
        opacity.to_s+";\n")
      file.write(s3+".graphic.blend_type="+p.graphic.\
        blend_type.to_s+";\n")
     
      # 移动路线
      file.write(s3+".move_type="+p.move_type.to_s+";\n")
      file.write(s3+".move_speed="+p.move_speed.to_s+";\n")
      file.write(s3+".move_frequency="+p.move_frequency.to_s+";\n")
      file.write(s3+".move_route=new Object();\n")
      file.write(s3+".move_route.repeat="+p.move_route.repeat.to_s+";\n")
      file.write(s3+".move_route.skippable="+p.move_route.skippable.to_s+";\n")
      file.write(s3+".move_route.list=new Array();\n")
     
      scr_ar=[]
      for k in 0..p.move_route.list.length-1
        l=p.move_route.list[k]
        s4=s3+".move_route.list["+k.to_s+"]"
        file.write(s4+"=new Object();\n")
        file.write(s4+".code="+l.code.to_s+";\n")
        next if (l.code==209)
        if l.code==45 # 如果是脚本,则加上字符串符号
          file.write(s4+".parameters="+$game_scripts.length.to_s+";\n")
          scr_ar.push(l.parameters[0])
        else
          file.write(s4+".parameters=["+l.parameters.join(",")+"];\n")
         
          # 如果还有脚本组未导出
          if (scr_ar.length>0)
            $game_scripts.push(scr_ar)
            scr_ar=[]
          end
        end
      end
     
      # 如果最后一条指令是脚本,也要导出脚本组
      $game_scripts.push(scr_ar) if (scr_ar.length>0)
     
      file.write(s3+".walk_anime="+p.walk_anime.to_s+";\n")
      file.write(s3+".step_anime="+p.step_anime.to_s+";\n") # 停止时动画
      file.write(s3+".direction_fix="+p.direction_fix.to_s+";\n")
      file.write(s3+".through="+p.through.to_s+";\n")
      file.write(s3+".always_on_top="+p.always_on_top.to_s+";\n")
      file.write(s3+".trigger="+p.trigger.to_s+";\n") # 触发条件
     
      # 输出执行内容
      file.write(s3+".list=new Array();\n")
      scr_ar=[]
      for k in 0..p.list.length-1
        l=p.list[k]
        next if (l.code==509 || l.code==209)
        next if (l.code==108 || l.code==408) # 跳过注释
       
        s4=s3+".list["+k.to_s+"]"
        file.write(s4+"=new Object();\n")
        file.write(s4+".code="+l.code.to_s+";\n")
        file.write(s4+".indent="+l.indent.to_s+";\n")
        if l.code==355 or l.code==655 # 脚本
          file.write(s4+".parameters=["+$game_scripts.length.to_s+"];\n")
          scr_ar.push(l.parameters[0])
        else
          pars=l.parameters
          if ([101,123,401].include?(l.code))
            pars[0]=pars[0].gsub(/\\(\w)/,"\\\\\\\\\\1")
            pars[0]=pars[0].gsub(/"/,"\\\"")
            pars[0]="\""+pars[0]+"\"" # 参数0加字符串符号
          end
          file.write(s4+".parameters=["+pars.join(",")+"];\n")
         
          # 如果还有脚本组未导出
          if (scr_ar.length>0)
            $game_scripts.push(scr_ar)
            scr_ar=[]
          end
        end
      end
    end
  end
end

file.write("        }\n");
file.write("    }\n")
file.write("}")
file.close()

一派護法 十九級
4樓 發表于:2015-12-6 10:48
【数据库 => 角色】
actors_infos=load_data("Data/Actors.rxdata")
actors_num=actors_infos.size

file=File.open("../RXData/Actors.as","w")
file.write("//这些代码是系统自动生成的,请不要修改这些代码\n")
file.write("\n")
file.write("package RXData\n")
file.write("{\n")
file.write("    public class Actors\n")
file.write("    {\n")
file.write("        public var num:int="+actors_num.to_s+";\n")
file.write("        public var party_members:Array=["+\
  system.party_members.join(",")+"];\n")
file.write("        public var actor:Array=new Array();\n")
file.write("        public function Actors()\n");
file.write("        {\n");

for i in 1..actors_infos.length-1
  actor=actors_infos[i]
  a="\t\t\tactor["+i.to_s+"]"
  file.write(a+"=new Object();\n")
  file.write(a+".name=\""+actor.name+"\";\n")
  file.write(a+".class_id="+actor.class_id.to_s+";\n")
  file.write(a+".initial_level="+actor.initial_level.to_s+";\n")
  file.write(a+".final_level="+actor.final_level.to_s+";\n")
  file.write(a+".exp_basis="+actor.exp_basis.to_s+";\n")
  file.write(a+".exp_inflation="+actor.exp_inflation.to_s+";\n")
  file.write(a+".character_name=\""+actor.character_name+"\";\n")
  file.write(a+".character_hue="+actor.character_hue.to_s+";\n")
  file.write(a+".battler_name=\""+actor.battler_name+"\";\n")
  file.write(a+".battler_hue="+actor.battler_hue.to_s+";\n")
  #file.write(a+".parameters=new Array();\n")
  file.write(a+".weapon_id="+actor.weapon_id.to_s+";\n")
  file.write(a+".armor1_id="+actor.armor1_id.to_s+";\n")
  file.write(a+".armor2_id="+actor.armor2_id.to_s+";\n")
  file.write(a+".armor3_id="+actor.armor3_id.to_s+";\n")
  file.write(a+".armor4_id="+actor.armor4_id.to_s+";\n")
  file.write(a+".weapon_fix="+actor.weapon_fix.to_s+";\n")
  file.write(a+".armor1_fix="+actor.armor1_fix.to_s+";\n")
  file.write(a+".armor2_fix="+actor.armor2_fix.to_s+";\n")
  file.write(a+".armor3_fix="+actor.armor3_fix.to_s+";\n")
  file.write(a+".armor4_fix="+actor.armor4_fix.to_s+";\n")
end

file.write("        }\n");
file.write("    }\n")
file.write("}")
file.close()
一派護法 十九級
5樓 發表于:2015-12-6 10:48
【解压数据库 => 图块】
tilesets_infos=load_data("Data/Tilesets.rxdata")
tilesets_num=tilesets_infos.size

file=File.open("../RXData/Tilesets.as","w")
file.write("//这些代码是系统自动生成的,请不要修改这些代码\n")
file.write("\n")
file.write("package RXData\n")
file.write("{\n")
file.write("    public class Tilesets\n")
file.write("    {\n")
file.write("        public var num:int="+tilesets_num.to_s+"; //图块总数\n")
file.write("        public var tileset:Array=new Array();\n")
file.write("        public function Tilesets()\n");
file.write("        {\n");

# 遍历所有图块
for tileset_id in 1..tilesets_num-1
  # 输出图块信息
  ar=tilesets_infos[tileset_id]
  s="\t\t\ttileset["+tileset_id.to_s+"]"
  file.write(s+"=new Object();\n")
  file.write(s+".name=\""+ar.name+"\";\n")
  file.write(s+".file_name=\""+ar.tileset_name+"\"; //地图元件图形\n")
  file.write(s+".autotile_names=new Array(); //自动元件图形\n")
  for i in 0..6
    file.write(s+".autotile_names["+i.to_s+"]=\"")
    file.write(ar.autotile_names[i])
    file.write("\";\n")
  end
 
  file.write(s+".panorama_name=\""+ar.panorama_name+"\"; //远景图像\n")
  file.write(s+".panorama_hue="+ar.panorama_hue.to_s+";\n")
  file.write(s+".fog_name=\""+ar.fog_name+"\";\n")
  file.write(s+".fog_hue="+ar.fog_hue.to_s+";\n")
  file.write(s+".fog_opacity="+ar.fog_opacity.to_s+";\n")
  file.write(s+".fog_blend_type="+ar.fog_blend_type.to_s+";\n")
  file.write(s+".fog_zoom="+ar.fog_zoom.to_s+";\n")
  file.write(s+".fog_sx="+ar.fog_sx.to_s+";\n")
  file.write(s+".fog_sy="+ar.fog_sy.to_s+";\n")
  file.write(s+".battleback_name=\""+ar.battleback_name+"\";\n")
 
  file.write(s+".passages=[")
  for i in 0..ar.passages.xsize-1
    h=ar.passages[i].to_s(16)
    h="0"+h if h.length==1
    file.write("0x"+h)
    file.write(",") if i!=ar.passages.xsize-1
  end
  file.write("];\n")
 
  file.write(s+".priorities=[")
  for i in 0..ar.priorities.xsize-1
    file.write(ar.priorities[i].to_s)
    file.write(",") if i!=ar.priorities.xsize-1
  end
  file.write("];\n")
 
  file.write(s+".terrain_tags=[")
  for i in 0..ar.terrain_tags.xsize-1
    file.write(ar.terrain_tags[i].to_s)
    file.write(",") if i!=ar.terrain_tags.xsize-1
  end
  file.write("];\n")
end

file.write("        }\n");
file.write("    }\n")
file.write("}")
file.close()
一派護法 十九級
6樓 發表于:2015-12-6 10:48
【解压事件中的脚本】
file=File.open("../__scripts.as","w")
file.write("//本代码是系统自动生成的,请不要修改这些代码\n")
file.write("\n")
file.write("package\n")
file.write("{\n")
file.write("    import RPG.*;\n")
file.write("    public class __scripts\n")
file.write("    {\n")
#file.write("        public var num:int="+$game_scripts.length.to_s+";\n")
file.write("        private var id:int;\n")
file.write("        public var event_id:int=-1;\n")
file.write("        public function __scripts(id:int):void\n")
file.write("        {\n")
file.write("            this.id=id;\n")
file.write("        }\n")
file.write("        public function execute():Boolean\n")
file.write("        {\n")

enter_flag=true # 上一条脚本是否换行
for i in 0..$game_scripts.length-1
  file.write("            if (this.id=="+i.to_s+")\n")
  file.write("            {\n")
  for j in 0..$game_scripts[i].length-1
    content=$game_scripts[i][j]
    file.write("                ") if enter_flag
    file.write(content)
    trc=trim(content)
   
    # 下面判断是否该换行
    if trc[-1,1]==";" or \
        /^[^;]*;[^;]*\/\/.*$/===trc or \
        /^\/\//===trc # 开头以“//”开始的脚本视为整行注释
     
      file.write("\n")
      enter_flag=true
    else
      enter_flag=false
    end
  end
  file.write("                return true;\n")
  file.write("            }\n")
end
file.write("            return false;\n")
file.write("        }\n")
file.write("    }\n")
file.write("}")
file.close()
一派護法 十九級
7樓 發表于:2015-12-6 10:48
# 你把脚本编辑器打开干嘛?
# Flash又不执行Ruby脚本
一派護法 十九級
8樓 發表于:2015-12-31 23:45
這段腳本現在棄之不用了。因為編寫上有問題。

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
(快捷鍵:Ctrl+Enter)
 

本帖信息

點擊數:544 回複數:7
評論數: ?
作者:巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2015-12-31 23:45
 
©2010-2024 Arslanbar Ver2.0
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。