查看: 2151|回复: 3

[已经解决] 求一个能用的存档管理脚本

[复制链接]
梦石
0
星屑
50
在线时间
9 小时
注册时间
2014-10-12
回帖
13
发表于 2014-10-17 18:02:43 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 DoloStar 于 2014-10-19 06:12 编辑

天干宝典里找到的档案管理
用读取和删除的时候提示错误
不然就是不能用...
有谁能分享一下嘛?
万分感谢

点评

LZ还是说下你需要的存档脚本有何功能吧,现在这样也不知道如何回答啊  发表于 2014-10-18 20:03
梦石
0
星屑
50
在线时间
9 小时
注册时间
2014-10-12
回帖
13
 楼主| 发表于 2014-10-19 06:13:21 | 显示全部楼层
@RyanBern 就是可以删除进度的脚本

点评

只有删除进度一个附加功能吗?如果是的话我可以做一个。  发表于 2014-10-19 09:23
回复

使用道具 举报

梦石
0
星屑
50
在线时间
9 小时
注册时间
2014-10-12
回帖
13
 楼主| 发表于 2014-10-19 16:34:54 | 显示全部楼层
DoloStar 发表于 2014-10-19 06:13
@RyanBern 就是可以删除进度的脚本

@RyanBern 如果可以带上一个读取功能OuO万分感谢
回复

使用道具 举报

梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2014-10-19 19:18:36 | 显示全部楼层
写了一个,我就不放范例了,脚本复制过去后如果出现SyntaxError就看看有么有Url什么的,去掉就是了。
有问题再找我吧。
  1. #============================================================================
  2. # 简易存档管理系统
  3. #----------------------------------------------------------------------------
  4. # By : RyanBern
  5. #============================================================================
  6. =begin

  7. 功能:把存档,读档,删档糅合到了一起,一个场景能实现三个功能。
  8. 档位增加到了6个。
  9. 注意,进行删档的时候不会有确认提示,会直接把档删了。如果要加确认提示的话,再联
  10. 系我吧。其实是我偷懒了。

  11. 脚本插入到Main前即可,没有对原始脚本改动,冲突可能性小。
  12. 需要手动改几个地方(如果对应行找不到就开一下搜索,在相应脚本内部搜即可)

  13. 1.Scene_Title,48行,for i in 0..3改成for i in 0..5
  14. 2.Scene_Title,157行,$scene = Scene_Load.new改成$scene = Scene_File_Manager.new(true)
  15. 3.Scene_Map,224行,$scene = Scene_Save.new改成$scene = Scene_File_Manager.new
  16. 4.Scene_Menu,160行,$scene = Scene_Save.new改成$scene = Scene_File_Manager.new

  17. 不想要这个脚本的时候记得把上面几处都改成原来的样子。

  18. =end
  19. class Window_File < Window_Selectable
  20.   def initialize
  21.     super(0, 128, 640, 352)
  22.     self.contents = Bitmap.new(width - 32, height - 32)
  23.     @item_max = 6
  24.     self.index = 0
  25.     refresh
  26.   end
  27.   def refresh
  28.     (0...6).each do |i|
  29.       draw_item(i)
  30.     end
  31.   end
  32.   def draw_item(index)
  33.     filename = "Save#{index + 1}.rxdata"
  34.     time_stamp = Time.at(0)
  35.     file_exist = FileTest.exist?(filename)
  36.     if file_exist
  37.       file = File.open(filename, "r")
  38.       time_stamp = file.mtime
  39.       characters = Marshal.load(file)
  40.       frame_count = Marshal.load(file)
  41.       game_system = Marshal.load(file)
  42.       game_switches = Marshal.load(file)
  43.       game_variables = Marshal.load(file)
  44.       total_sec = frame_count / Graphics.frame_rate
  45.       file.close
  46.     end
  47.     x = 4
  48.     y = index * 52
  49.     self.contents.fill_rect(x, y, self.contents.width - 4, 52, Color.new(0,0,0,0))
  50.     self.contents.font.size = 18
  51.     # 描绘文件编号
  52.     self.contents.font.color = normal_color
  53.     name = "文件 #{index + 1}"
  54.     self.contents.draw_text(4, y, 54, 32, name)
  55.     @name_width = contents.text_size(name).width
  56.     # 存档文件存在的情况下
  57.     if file_exist
  58.       # 描绘角色
  59.       for i in 0...characters.size
  60.         bitmap = RPG::Cache.character(characters[i][0], characters[i][1])
  61.         cw = bitmap.rect.width / 4
  62.         ch = bitmap.rect.height / 4
  63.         src_rect = Rect.new(0, 0, cw, ch)
  64.         cx = 96 + i * (cw + 8)
  65.         self.contents.blt(cx, y + (52 - ch) / 2, bitmap, src_rect)
  66.       end
  67.       # 描绘游戏时间
  68.       hour = total_sec / 60 / 60
  69.       min = total_sec / 60 % 60
  70.       sec = total_sec % 60
  71.       time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  72.       self.contents.font.size = 16
  73.       self.contents.font.color = normal_color
  74.       self.contents.draw_text(x + 444, y, 160, 24, time_string, 2)
  75.       # 描绘时间标记
  76.       self.contents.font.color = normal_color
  77.       time_string = time_stamp.strftime("%Y/%m/%d %H:%M")
  78.       self.contents.draw_text(x + 444, y + 24, 160, 24, time_string, 2)
  79.     end
  80.   end
  81.   def update_cursor_rect
  82.     if @index < 0
  83.       self.cursor_rect.empty
  84.     else
  85.       self.cursor_rect.set(0, @index * 52, self.width - 32, 52)
  86.     end
  87.   end
  88. end

  89. class Window_File_Command < Window_Selectable
  90.   def initialize
  91.     super(0, 64, 640, 64)
  92.     self.contents = Bitmap.new(width - 32, height - 32)
  93.     @column_max = 3
  94.     @item_max = 3
  95.     self.index = 0
  96.     @commands = ["存档", "读档", "档案管理"]
  97.     refresh
  98.   end
  99.   def refresh
  100.     (0...3).each do |i|
  101.       draw_item(i)
  102.     end
  103.   end
  104.   def draw_item(index, color = normal_color)
  105.     x = 4 + index * width / @column_max
  106.     y = 0
  107.     w = self.contents.width / @column_max
  108.     self.contents.fill_rect(x, y, w, 32, Color.new(0,0,0,0))
  109.     self.contents.font.color = color
  110.     self.contents.draw_text(x, y, w, 32, @commands[index])
  111.   end
  112.   def disable_item(index)
  113.     draw_item(index, disabled_color)
  114.   end
  115.   def update_help
  116.     texts = ["保存当前进度", "读取已有进度", "进行存档管理"]
  117.     @help_window.set_text(texts[self.index])
  118.   end
  119. end

  120. class Scene_File_Manager
  121.   def initialize(save_disabled = false)
  122.     @save_disabled = save_disabled
  123.   end
  124.   def main
  125.     @dummy_window = Window_Base.new(0, 128, 640, 352)
  126.     @help_window = Window_Help.new
  127.     @file_window = Window_File.new
  128.     @file_window.visible = false
  129.     @file_window.active = false
  130.     @command_window = Window_File_Command.new
  131.     @command_window.help_window = @help_window
  132.     if @save_disabled
  133.       @command_window.disable_item(0)
  134.     end
  135.     Graphics.transition
  136.     loop do
  137.       Graphics.update
  138.       Input.update
  139.       update
  140.       if $scene != self
  141.         break
  142.       end
  143.     end
  144.     Graphics.freeze
  145.     @dummy_window.dispose
  146.     @help_window.dispose
  147.     @command_window.dispose
  148.     @file_window.dispose
  149.   end
  150.   def update
  151.     @file_window.update
  152.     @command_window.update
  153.     if @command_window.active
  154.       update_command
  155.       return
  156.     end
  157.     if @file_window.active
  158.       update_file
  159.     end
  160.   end
  161.   def update_command
  162.     if Input.trigger?(Input::B)
  163.       $game_system.se_play($data_system.cancel_se)
  164.       if $game_temp.save_calling
  165.         $game_temp.save_calling = false
  166.         $scene = Scene_Map.new
  167.       elsif @save_disbled
  168.         $scene = Scene_Title.new
  169.       else
  170.         $scene = Scene_Menu.new(5)
  171.       end
  172.       return
  173.     end
  174.     if Input.trigger?(Input::C)
  175.       if @save_disabled && @command_window.index == 0
  176.         $game_system.se_play($data_system.buzzer_se)
  177.         return
  178.       end
  179.       $game_system.se_play($data_system.decision_se)
  180.       @command_window.active = false
  181.       @dummy_window.visible = false
  182.       @file_window.visible = true
  183.       @file_window.active = true
  184.       return
  185.     end
  186.   end
  187.   def update_file
  188.     if Input.trigger?(Input::B)
  189.       $game_system.se_play($data_system.cancel_se)
  190.       @file_window.visible = false
  191.       @file_window.active = false
  192.       @dummy_window.visible = true
  193.       @command_window.active = true
  194.       return
  195.     end
  196.     if Input.trigger?(Input::C)
  197.       filename = "Save#{@file_window.index + 1}.rxdata"
  198.       case @command_window.index
  199.       when 0
  200.         $game_system.se_play($data_system.save_se)
  201.         write_save_data(filename)
  202.         if $game_temp.save_calling
  203.           $game_temp.save_calling = false
  204.           $scene = Scene_Map.new
  205.         else
  206.           $scene = Scene_Menu.new(5)
  207.         end
  208.         return
  209.       when 1
  210.         if FileTest.exist?(filename)
  211.           $game_system.se_play($data_system.load_se)
  212.           $game_temp = Game_Temp.new
  213.           read_save_data(filename)
  214.           $game_system.bgm_play($game_system.playing_bgm)
  215.           $game_system.bgs_play($game_system.playing_bgs)
  216.           $game_map.update
  217.           $scene = Scene_Map.new
  218.         else
  219.           $game_system.se_play($data_system.buzzer_se)
  220.         end
  221.         return
  222.       when 2
  223.         if FileTest.exist?(filename)
  224.           $game_system.se_play($data_system.decision_se)
  225.           File.delete(filename)
  226.           @file_window.draw_item(@file_window.index)
  227.         else
  228.           $game_system.se_play($data_system.buzzer_se)
  229.         end
  230.         return
  231.       end
  232.     end
  233.   end
  234.   def write_save_data(filename)
  235.     file = File.open(filename, "wb")
  236.     characters = []
  237.     for i in 0...$game_party.actors.size
  238.       actor = $game_party.actors[i]
  239.       characters.push([actor.character_name, actor.character_hue])
  240.     end
  241.     Marshal.dump(characters, file)
  242.     Marshal.dump(Graphics.frame_count, file)
  243.     $game_system.save_count += 1
  244.     $game_system.magic_number = $data_system.magic_number
  245.     Marshal.dump($game_system, file)
  246.     Marshal.dump($game_switches, file)
  247.     Marshal.dump($game_variables, file)
  248.     Marshal.dump($game_self_switches, file)
  249.     Marshal.dump($game_screen, file)
  250.     Marshal.dump($game_actors, file)
  251.     Marshal.dump($game_party, file)
  252.     Marshal.dump($game_troop, file)
  253.     Marshal.dump($game_map, file)
  254.     Marshal.dump($game_player, file)
  255.     file.close
  256.   end
  257.   def read_save_data(filename)
  258.     file = File.open(filename, "rb")
  259.     characters = Marshal.load(file)
  260.     Graphics.frame_count = Marshal.load(file)
  261.     $game_system        = Marshal.load(file)
  262.     $game_switches      = Marshal.load(file)
  263.     $game_variables     = Marshal.load(file)
  264.     $game_self_switches = Marshal.load(file)
  265.     $game_screen        = Marshal.load(file)
  266.     $game_actors        = Marshal.load(file)
  267.     $game_party         = Marshal.load(file)
  268.     $game_troop         = Marshal.load(file)
  269.     $game_map           = Marshal.load(file)
  270.     $game_player        = Marshal.load(file)
  271.     if $game_system.magic_number != $data_system.magic_number
  272.       $game_map.setup($game_map.map_id)
  273.       $game_player.center($game_player.x, $game_player.y)
  274.     end
  275.     $game_party.refresh
  276.     file.close
  277.   end
  278. end
复制代码

点评

能用OuO也没什么问题 非常感谢  发表于 2014-10-20 00:12
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部