设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1841|回复: 4
打印 上一主题 下一主题

[已经过期] 存檔衝突,請教一下如何處裡?

[复制链接]

Lv2.观梦者

梦石
0
星屑
257
在线时间
58 小时
注册时间
2009-5-25
帖子
39
跳转到指定楼层
1
发表于 2011-11-1 00:42:48 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 ainlee 于 2011-11-1 00:47 编辑

如附圖
只要選到存檔就掛!

該行錯誤,但該行我看跟原本的專案一樣

所以我猜是◎ Scene_File有錯吧?(我有使用沉影大大的新樣式)
  1. #==============================================================================
  2. # ■ Scene_File
  3. #==============================================================================
  4. class Scene_File < Scene_Menu_Base
  5.   #--------------------------------------------------------------------------
  6.   # ◎ 初始化對象
  7.   #     saving     : 存檔標誌 (false 為載入畫面)
  8.   #     from_title : 調用標題畫面的 "繼續" 標誌
  9.   #     from_event : 事件的 "調用存檔畫面" 的調用標誌
  10.   #--------------------------------------------------------------------------
  11.   def initialize(saving, from_title, from_event)
  12.     @saving = saving
  13.     @from_title = from_title
  14.     @from_event = from_event
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ◎ 開始處理
  18.   #--------------------------------------------------------------------------
  19.   def start
  20.     super
  21.     @help_window = Window_Help.new
  22.     if $game_temp.menu_bitmap.width == 1
  23.       @menu_command_window = Window_Base.new(0,360,544,56)
  24.       create_title_graphic
  25.     end
  26.     create_choice_window
  27.     create_file_command_window
  28.     if @saving
  29.       @index = $game_temp.last_file_index
  30.       @help_window.set_text(Vocab::SaveMessage)
  31.     else
  32.       @index = self.latest_file_index
  33.       @help_window.set_text(Vocab::LoadMessage)
  34.     end
  35.     @refresh_index = @file_command_window.index = @index
  36.     @item_max = MAX_SAVE_ID
  37.     create_savefile_window
  38.     @savefile_window.openness = 0
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ◎ 結束處理
  42.   #--------------------------------------------------------------------------
  43.   def terminate
  44.     @@menu_index = @menu_command_window.index unless @from_title
  45.     @menu_command_window.dispose
  46.     @help_window.dispose
  47.     dispose_item_windows
  48.     dispose_menu_background
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ◎ 還原至原先的畫面
  52.   #--------------------------------------------------------------------------
  53.   def return_scene
  54.     if @from_title
  55.       $scene = Scene_Title.new
  56.     elsif @from_event
  57.       $scene = Scene_Map.new
  58.     else
  59.       $scene = Scene_Menu.new(@@menu_index)
  60.     end
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ◎ 更新畫面
  64.   #--------------------------------------------------------------------------
  65.   def update
  66.     super
  67.     @help_window.update
  68.     if @choice_window.visible
  69.       update_choice_window
  70.     else
  71.       update_savefile_windows
  72.       update_savefile_selection
  73.     end
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ◎ 開始後處理
  77.   #--------------------------------------------------------------------------
  78.   def post_start
  79.     super
  80.     open_savefile_window
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ◎ 結束前處理
  84.   #--------------------------------------------------------------------------
  85.   def pre_terminate
  86.     super
  87.     close_savefile_window
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ◎ 生成標題畫面背景
  91.   #--------------------------------------------------------------------------
  92.   def create_title_graphic
  93.     @menuback_sprite = Sprite.new
  94.     @menuback_sprite.bitmap = Cache.system("Title")
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ○ 生成指令視窗
  98.   #     index : 默認項目編號
  99.   #--------------------------------------------------------------------------
  100.   def create_menu_command_window(index = 0)
  101.     s1 = Vocab::item
  102.     s2 = Vocab::skill
  103.     s3 = Vocab::equip
  104.     s4 = Vocab::status
  105.     s5 = Vocab::save
  106.     s6 = Vocab::game_end
  107.     s7 = "陣型設定"
  108.     @menu_command_window = Window_Menu_Command.new(544, [s1, s2, s3, s4, s7, s5, s6])
  109.     @menu_command_window.y = @show ? 416 : 360
  110.     @menu_command_window.index = index
  111.     @menu_command_window.refresh
  112.     if $game_party.members.size == 0          # 同伴人數為 0 的情況下
  113.       @menu_command_window.draw_item(0, false)     # 物品無效化
  114.       @menu_command_window.draw_item(1, false)     # 特技無效化
  115.       @menu_command_window.draw_item(2, false)     # 裝備無效化
  116.       @menu_command_window.draw_item(3, false)     # 狀態無效化
  117.       @command_window.draw_item(4, false)     # 陣形編成を無効化
  118.     end
  119.     if $game_switches[AGOW::FORMATION::CALL_SCENE_SWI] == false
  120.       @command_window.draw_item(4, false)     # 陣形編成を無効化
  121.     end
  122.     if $game_system.save_disabled             # 禁止存檔的情況下
  123.       @menu_command_window.draw_item(5, false)     # 存檔無效化
  124.     end
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ◎ 生成存檔檔清單窗口
  128.   #--------------------------------------------------------------------------
  129.   def create_file_command_window
  130.     file_names = []
  131.     digit = MAX_SAVE_ID.to_s.size
  132.     str_f = ""
  133.     digit.times{|n| str_f += "0"}
  134.     str_f[str_f.size-1, 1] = digit.to_s
  135.     for i in 0...MAX_SAVE_ID
  136.       id = sprintf("%#{str_f}d", i+1)
  137.       file_names.push(Vocab::File + "\s" + id)
  138.     end
  139.     @file_command_window = Window_Command.new(112, file_names)
  140.     @file_command_window.height = 298
  141.     @file_command_window.x = 64
  142.     @file_command_window.y = 59
  143.     @file_command_window.openness = 0
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ◎ 生成覆蓋提示表單
  147.   #--------------------------------------------------------------------------
  148.   def create_choice_window
  149.     @choice_window = Window_Choice.new
  150.     @choice_window.visible = false
  151.     @choice_window.z = 999
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # ◎ 生成檔案名
  155.   #     file_index : 存檔檔索引
  156.   #--------------------------------------------------------------------------
  157.   def make_filename(file_index)
  158.     return "Save#{file_index + 1}.rvdata"
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ◎ 生成存檔檔窗口
  162.   #--------------------------------------------------------------------------
  163.   def create_savefile_window
  164.     @savefile_window = Window_SaveFile.new(@file_command_window.index, make_filename(@file_command_window.index))
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # ◎ 釋放存檔檔
  168.   #--------------------------------------------------------------------------
  169.   def dispose_item_windows
  170.     @file_command_window.dispose
  171.     @savefile_window.dispose
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ◎ 打開指令視窗
  175.   #--------------------------------------------------------------------------
  176.   def open_savefile_window
  177.     @file_command_window.open
  178.     @savefile_window.open
  179.     begin
  180.       @file_command_window.update
  181.       @savefile_window.update
  182.       Graphics.update
  183.     end until @savefile_window.openness == 255
  184.   end
  185.   #--------------------------------------------------------------------------
  186.   # ◎ 關閉指令視窗
  187.   #--------------------------------------------------------------------------
  188.   def close_savefile_window
  189.     @file_command_window.close
  190.     @savefile_window.close
  191.     begin
  192.       @file_command_window.update
  193.       @savefile_window.update
  194.       Graphics.update
  195.     end until @savefile_window.openness == 0
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # ◎ 更新存檔檔窗口
  199.   #--------------------------------------------------------------------------
  200.   def update_savefile_windows
  201.     @file_command_window.update
  202.     @savefile_window.update
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ◎ 更新存檔檔選擇
  206.   #--------------------------------------------------------------------------
  207.   def update_savefile_selection
  208.     if Input.trigger?(Input::C)
  209.       determine_savefile
  210.     end
  211.     if Input.trigger?(Input::B)
  212.       Sound.play_cancel
  213.       return_scene
  214.     end
  215.     if @refresh_index != @file_command_window.index
  216.       @refresh_index = @file_command_window.index
  217.       @savefile_window.dispose
  218.       create_savefile_window
  219.     end
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # ◎ 更新覆蓋提示表單
  223.   #--------------------------------------------------------------------------
  224.   def update_choice_window
  225.     @choice_window.update
  226.     if Input.trigger?(Input::C)
  227.       if @choice_window.value
  228.         Sound.play_save
  229.         do_save
  230.       else
  231.         Sound.play_cancel
  232.       end
  233.       @choice_window.visible = false
  234.     elsif Input.trigger?(Input::B)
  235.       Sound.play_cancel
  236.       @choice_window.visible = false
  237.     end
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ◎ 確定存檔檔
  241.   #--------------------------------------------------------------------------
  242.   def determine_savefile
  243.     if @saving
  244.       if @savefile_window.file_exist
  245.         @choice_window.visible = true
  246.       else
  247.         Sound.play_save
  248.         do_save
  249.       end
  250.     else
  251.       if @savefile_window.file_exist
  252.         Sound.play_load
  253.         do_load
  254.       else
  255.         Sound.play_buzzer
  256.         return
  257.       end
  258.     end
  259.     $game_temp.last_file_index = @index
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   # ◎ 生成檔案名
  263.   #     file_index : 存檔檔索引 (0~3)
  264.   #--------------------------------------------------------------------------
  265.   def make_filename(file_index)
  266.     return "Save#{file_index + 1}.rvdata"
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ◎ 按時間戳記選擇最新的文件
  270.   #--------------------------------------------------------------------------
  271.   def latest_file_index
  272.     index = 0
  273.     latest_time = Time.at(0) # 時間戳記
  274.     for i in 0...MAX_SAVE_ID
  275.       file_name = make_filename(i)
  276.       if FileTest.exist?(SAVE_DIR + file_name)
  277.         file = File.open(SAVE_DIR + file_name, "r")
  278.         if file.mtime > latest_time
  279.           latest_time = file.mtime
  280.           index = i
  281.         end
  282.       end
  283.     end
  284.     return index
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # ◎ 執行存檔
  288.   #--------------------------------------------------------------------------
  289.   def do_save
  290.     file_name = make_filename(@file_command_window.index)
  291.     file = File.open(SAVE_DIR + file_name, "wb")
  292.     write_save_data(file)
  293.     # 保存點陣圖
  294.     file_bitmap = $game_temp.save_bitmap.clone
  295.     Marshal.dump(file_bitmap, file)
  296.     file.close
  297.     file_bitmap.dispose
  298.     return_scene
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # ◎ 執行載入
  302.   #--------------------------------------------------------------------------
  303.   def do_load
  304.     file_name = make_filename(@file_command_window.index)
  305.     file = File.open(SAVE_DIR + file_name, "rb")
  306.     read_save_data(file)
  307.     file.close
  308.     $scene = Scene_Map.new
  309.     RPG::BGM.fade(1500)
  310.     Graphics.fadeout(60)
  311.     Graphics.wait(40)
  312.     @last_bgm.play
  313.     @last_bgs.play
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # ● 寫入存檔資料
  317.   #     file : 寫入檔用物件 (已經打開)
  318.   #--------------------------------------------------------------------------
  319.   def write_save_data(file)
  320.     characters = []
  321.     for actor in $game_party.members
  322.       characters.push([actor.character_name, actor.character_index])
  323.     end
  324.     $game_system.save_count += 1
  325.     $game_system.version_id = $data_system.version_id
  326.     @last_bgm = RPG::BGM::last
  327.     @last_bgs = RPG::BGS::last
  328.     Marshal.dump(characters,           file)
  329.     Marshal.dump(Graphics.frame_count, file)
  330.     Marshal.dump(@last_bgm,            file)
  331.     Marshal.dump(@last_bgs,            file)
  332.     Marshal.dump($game_system,         file)
  333.     Marshal.dump($game_message,        file)
  334.     Marshal.dump($game_switches,       file)
  335.     Marshal.dump($game_variables,      file)
  336.     Marshal.dump($game_self_switches,  file)
  337.     Marshal.dump($game_actors,         file)
  338.     Marshal.dump($game_party,          file)
  339.     Marshal.dump($game_troop,          file)
  340.     Marshal.dump($game_map,            file)
  341.     Marshal.dump($game_player,         file)
  342.   end
  343.   #--------------------------------------------------------------------------
  344.   # ● 讀取存檔數據
  345.   #     file : 讀取檔用物件 (已經打開)
  346.   #--------------------------------------------------------------------------
  347.   def read_save_data(file)
  348.     characters           = Marshal.load(file)
  349.     Graphics.frame_count = Marshal.load(file)
  350.     @last_bgm            = Marshal.load(file)
  351.     @last_bgs            = Marshal.load(file)
  352.     $game_system         = Marshal.load(file)
  353.     $game_message        = Marshal.load(file)
  354.     $game_switches       = Marshal.load(file)
  355.     $game_variables      = Marshal.load(file)
  356.     $game_self_switches  = Marshal.load(file)
  357.     $game_actors         = Marshal.load(file)
  358.     $game_party          = Marshal.load(file)
  359.     $game_troop          = Marshal.load(file)
  360.     $game_map            = Marshal.load(file)
  361.     $game_player         = Marshal.load(file)
  362.     if $game_system.version_id != $data_system.version_id
  363.       $game_map.setup($game_map.map_id)
  364.       $game_player.center($game_player.x, $game_player.y)
  365.     end
  366.   end
  367. end
复制代码
對於這一串亂碼我實在是很沒辦法
光是加入個陣型的選單我就搞了老半天....
現在其實不只這個衝突
但我想一個一個解決好了~
希望各位大大可以幫幫忙~
必要時我可以上傳專案
16bit的趙雲

Lv1.梦旅人

星君

梦石
0
星屑
83
在线时间
2980 小时
注册时间
2011-10-9
帖子
2317

贵宾短篇七萝莉正太组冠军

2
发表于 2011-11-1 01:13:46 | 只看该作者
囧,只是因为你把菜单设定错了,才会这样
默认脚本中,when 4是存档
LZ把那个换了,添加新的了
但是在54行到60行的那些Vocab里面没有添加
还有60行的command_window
试试替换成这样:
  1.     s1 = Vocab::item
  2.     s2 = Vocab::skill
  3.     s3 = Vocab::equip
  4.     s4 = Vocab::status
  5.     s5 = "队伍"
  6.     s6 = Vocab::save
  7.     s7 = Vocab::game_end
  8.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
复制代码
PS:$scene = Scene_Menu.new神马的自己设置(逃)

回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
257
在线时间
58 小时
注册时间
2009-5-25
帖子
39
3
 楼主| 发表于 2011-11-1 23:56:17 | 只看该作者
54行到60行是:
  1.     if @from_title
  2.       $scene = Scene_Title.new
  3.     elsif @from_event
  4.       $scene = Scene_Map.new
  5.     else
  6.       $scene = Scene_Menu.new(@@menu_index)
  7.     end
复制代码
請問要加什麼呢?
不好意思我真的不太懂這個....

点评

是Scene_Menu不是Scene_Save  发表于 2011-11-3 00:08
16bit的趙雲
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
134 小时
注册时间
2009-3-29
帖子
470
4
发表于 2011-11-3 00:05:13 | 只看该作者
这里是对着来的。上面改什么,下面就要改什么。


s1对应when0  s2对应when1 ......
记得还要修改P1最后一行。[s1, s2, s3, s4, s5, s6]  ←这里你可以自己加多

黑之结界勇士
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
257
在线时间
58 小时
注册时间
2009-5-25
帖子
39
5
 楼主| 发表于 2011-11-3 22:38:49 | 只看该作者
本帖最后由 ainlee 于 2011-11-3 22:40 编辑

我已改好對應號碼了~
不過還是失敗~


怎麼會這樣?
附件是我的專案~
請懂得人幫忙看一下~
我的專案
16bit的趙雲
回复

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-21 05:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表