作者共發了6篇帖子。
【教程】給一個RMXP工程加上多文件存檔功能
1樓 巨大八爪鱼 2013-7-7 16:42
本文章詳細講解如何對RMXP工程加上多文件存檔功能,並將轉換現有的存檔。
如果你是用的魔塔樣板做的,就不要看這篇文章了。這篇文章的內容只能在純RMXP新建的工程下使用,在魔塔樣板下使用會出錯的(主要是開關4的問題),況且現在所有的魔塔樣板都已經有這個功能了。
首先要明確的一點是,存檔文件的保存位置。默認rmxp新建的工程(簡稱R工程)存檔文件只能有4個,而且還存在工程根目錄下的。由於我們要設置多文件的存檔,所以防在根目錄下很麻煩。因此,我們把存檔文件都放在單獨的一個文件夾中——Save文件夾。
為了防止玩家從其他魔塔中存檔,並把該存檔複製到本遊戲來作弊,所以我們增加了密鑰的功能。注意每個遊戲的密鑰最好不要相同。
在腳本編輯器中新加一個腳本■protect savefile,內容:
2樓 巨大八爪鱼 2013-7-7 16:44
#==============================================================================
# ☆★☆ Custom Save☆★☆
#------------------------------------------------------------------------------
# - FantasyDR
#------------------------------------------------------------------------------
# MSN: [email]FantasyDR_SJL@hotmail.com[/email]
#------------------------------------------------------------------------------
# - 2006.7.18
#------------------------------------------------------------------------------
# 自定義存檔數據排列順序並校驗存檔
#==============================================================================
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
#  存檔畫面及讀檔畫面的超級類。
#==============================================================================
class Scene_File
#--------------------------------------------------------------------------
# ● 存檔密鑰,請定義成自己的密鑰
#   密鑰不同的存檔將無法被讀取
#--------------------------------------------------------------------------
SAVE_KEY = 3975
#發佈自己的魔塔遊戲時,請一定要把上面的數字換掉
#--------------------------------------------------------------------------
# ● 常量 (存檔頁數)
#--------------------------------------------------------------------------
MaxPages = 8
 #--------------------------------------------------------------------------
 # ● 初始化對像
 #     help_text : 幫助窗口顯示的字符串
 #--------------------------------------------------------------------------
 def initialize(help_text)
   @help_text = help_text
   @slots = MaxPages * 4
 end
 #--------------------------------------------------------------------------
 # ● 主處理
 #--------------------------------------------------------------------------
 def main
   # 生成幫助窗口
   @help_window = Window_Help.new
   @help_window.set_text(@help_text)
   @file_index = $game_temp.last_file_index
   # 生成存檔文件窗口
   @savefile_windows = []
   # 選擇最後操作的文件
   for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
     load_window(i)
     @savefile_windows[i].visible = true
   end
   @savefile_windows[@file_index].selected = true
   # 執行過渡
   Graphics.transition
   # 主循環
   loop do
     # 刷新遊戲畫面
     Graphics.update
     # 刷新輸入信息
     Input.update
     # 刷新畫面
     update
     # 如果畫面被切換的話就中斷循環
     if $scene != self
       break
     end
   end
  
# 準備過渡
  Graphics.freeze
  # 釋放窗口
  @help_window.dispose
  for i in 0...@slots
    @savefile_windows[i].dispose if @savefile_windows[i] != nil
  end
end
#--------------------------------------------------------------------------
# ● 刷新畫面
#--------------------------------------------------------------------------
def update
  # 刷新窗口
  @help_window.update
  for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
    @savefile_windows[i].update if @savefile_windows[i].visible
  end
   # 按下 C 鍵的情況下
   if Input.trigger?(Input::C)
     # 調用過程 on_decision (定義繼承目標)
     on_decision(make_filename(@file_index))
     $game_temp.last_file_index = @file_index
     return
   end
   # 按下 B 鍵的情況下
   if Input.trigger?(Input::B)
     # 調用過程 on_cancel (定義繼承目標)
     on_cancel
     return
   end
   # 按下方向鍵下的情況下
   if Input.repeat?(Input::DOWN)
     # 演奏光標 SE
     $game_system.se_play($data_system.cursor_se)
     # 光標向下移動
     @savefile_windows[@file_index].selected = false
     @file_index = (@file_index + 1) % @slots
     # 翻到下一頁的情況下
     if @file_index % 4 == 0
       for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
         @savefile_windows[(index + @slots - 4) % @slots].visible = false
         load_window(index)
         @savefile_windows[index].visible = true
       end
     end
     @savefile_windows[@file_index].selected = true
     return
   end
   # 按下方向鍵上的情況下
   if Input.repeat?(Input::UP)
     # 演奏光標 SE
     $game_system.se_play($data_system.cursor_se)
     # 光標向上移動
     @savefile_windows[@file_index].selected = false
     @file_index = (@file_index + @slots - 1) % @slots
     # 翻到上一頁的情況下
     if @file_index % 4 == 3
       for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
         @savefile_windows[(index + 4) % @slots].visible = false
         load_window(index)
         @savefile_windows[index].visible = true
       end
     end
     @savefile_windows[@file_index].selected = true
     return
   end
   # 按下方向鍵左或者 L 的情況下
   if Input.repeat?(Input::LEFT) or Input.trigger?(Input::L)
     # 演奏光標 SE
     $game_system.se_play($data_system.cursor_se)
     # 前翻一頁
     @savefile_windows[@file_index].selected = false
     @file_index = (@file_index + @slots - 4) % @slots
     for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
       @savefile_windows[(index + 4) % @slots].visible = false
       load_window(index)
       @savefile_windows[index].visible = true
     end
     @savefile_windows[@file_index].selected = true
     return
   end
   # 按下方向鍵右或者 R 的情況下
   if Input.repeat?(Input::RIGHT) or Input.trigger?(Input::R)
     # 演奏光標 SE
     $game_system.se_play($data_system.cursor_se)
     # 前翻一頁
     @savefile_windows[@file_index].selected = false
     @file_index = (@file_index + 4) % @slots
     for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
       @savefile_windows[(index + @slots - 4) % @slots].visible = false
       load_window(index)
       @savefile_windows[index].visible = true
     end
     @savefile_windows[@file_index].selected = true
     return
   end
 end
 #--------------------------------------------------------------------------
 # ● 生成文件名
 #     file_index : 文件名的索引 (0~n)
 #--------------------------------------------------------------------------
 def make_filename(file_index)
   return "Save/motaSave#{file_index + 1}.rxdata"
 end
 #--------------------------------------------------------------------------
 # ● 載入當前頁存檔
 #     避免因存檔位過多造成的卡殼現象
 #--------------------------------------------------------------------------
 def load_window(i)
   if @savefile_windows[i] != nil
     return
   else
     @savefile_windows[i] = Window_SaveFile.new(i, make_filename(i))
   end
 end
end
#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
#  處理讀檔畫面的類。
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# ● 初始化對像
#--------------------------------------------------------------------------
def initialize()#save_max = SAVE_MAX)
  # 再生成臨時對像
  $game_temp = Game_Temp.new
  # 選擇存檔時間最新的文件
  $game_temp.last_file_index = 0
  latest_time = Time.at(0)
  for i in 0..7
    filename = make_filename(i)
    if FileTest.exist?(filename)
    begin
      file = Zlib::GzipReader.open(filename)
    rescue
      next
    end
    if file.mtime > latest_time
      latest_time = file.mtime
      $game_temp.last_file_index = i
    end
    file.close
    end
  end
  super("要載入哪個文件?")#,"讀取",save_max)
end
#--------------------------------------------------------------------------
# ● 確定時的處理
#--------------------------------------------------------------------------
def on_decision(filename)
  # 文件不存在的情況下
  unless FileTest.exist?(filename)
    # 演奏凍結 SE
    $game_system.se_play($data_system.buzzer_se)
    return
  end
  # 演奏讀檔 SE
  $game_system.se_play($data_system.load_se)
  # 寫入存檔數據
  begin
    file = Zlib::GzipReader.open(filename)
    read_save_data(file)
  rescue
    # 演奏凍結 SE
    $game_system.se_play($data_system.buzzer_se)
    return
  end
  file.close
  # 還原 BGM、BGS
  $game_system.bgm_play($game_system.playing_bgm)
  $game_system.bgs_play($game_system.playing_bgs)
  # 刷新地圖 (執行並行事件)
  $game_map.update
  # 切換到地圖畫面
  $scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 取消時的處理
#--------------------------------------------------------------------------
def on_cancel
  # 演奏取消 SE
  $game_system.se_play($data_system.cancel_se)
  # 切換到標題畫面
  $scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# ● 讀取存檔數據
#   file : 讀取用文件對像 (已經打開)
#--------------------------------------------------------------------------
def read_save_data(file)
 
  $desc=Marshal.load(file) 
  # 讀取描繪存檔文件用的角色數據
  characters = Marshal.load(file)
  # 讀取測量遊戲時間用畫面計數
  Graphics.frame_count = Marshal.load(file)
  # 讀取校驗
  crcs = Marshal.load(file)
  # 讀取文檔字串
  strings = Marshal.load(file)
  # 校驗檢測
  key = SAVE_KEY
  strings.each_index do |i|
    key = Zlib.crc32(strings[i],key)
    unless crcs[i] == key
    file.close
    raise "file check error"
    return
    end
  end
  # 讀取各種遊戲對像
  $game_system = Marshal.load(Zlib::Inflate.inflate(strings[0]))
  $game_variables = Marshal.load(Zlib::Inflate.inflate(strings[1]))
  $game_self_switches = Marshal.load(Zlib::Inflate.inflate(strings[2]))
  $game_switches = Marshal.load(Zlib::Inflate.inflate(strings[3]))
  $game_troop = Marshal.load(Zlib::Inflate.inflate(strings[4]))
  $game_map = Marshal.load(Zlib::Inflate.inflate(strings[5]))
  $game_player = Marshal.load(Zlib::Inflate.inflate(strings[6]))
  $game_screen = Marshal.load(Zlib::Inflate.inflate(strings[7]))
  $game_actors = Marshal.load(Zlib::Inflate.inflate(strings[8]))
  $game_party = Marshal.load(Zlib::Inflate.inflate(strings[9]))
  $floorenemies = Marshal.load(Zlib::Inflate.inflate(strings[10]))
  $fledam = Marshal.load(Zlib::Inflate.inflate(strings[11]))
#  $data_enemies = Marshal.load(Zlib::Inflate.inflate(strings[12]))
 
  # 魔法編號與保存時有差異的情況下
  # (加入編輯器的編輯過的數據)
  if $game_system.magic_number != $data_system.magic_number
    # 重新裝載地圖
    $game_map.setup($game_map.map_id)
    $game_player.center($game_player.x, $game_player.y)
  end
  # 刷新同伴成員
  $game_party.refresh
end
end

#==============================================================================
# ■ Scene_Load2
#------------------------------------------------------------------------------
#  處理讀檔畫面的類。
#==============================================================================
class Scene_Load2 < Scene_File
#--------------------------------------------------------------------------
# ● 初始化對像
#--------------------------------------------------------------------------
def initialize()#save_max = SAVE_MAX)
  # 再生成臨時對像
  $game_temp = Game_Temp.new
  # 選擇存檔時間最新的文件
  $game_temp.last_file_index = 0
  latest_time = Time.at(0)
  for i in 0..7
    filename = make_filename(i)
    if FileTest.exist?(filename)
    begin
      file = Zlib::GzipReader.open(filename)
    rescue
      next
    end
    if file.mtime > latest_time
      latest_time = file.mtime
      $game_temp.last_file_index = i
    end
    file.close
    end
  end
  super("要載入哪個文件?")#,"讀取",save_max)
end
#--------------------------------------------------------------------------
# ● 確定時的處理
#--------------------------------------------------------------------------
def on_decision(filename)
  # 文件不存在的情況下
  unless FileTest.exist?(filename)
    # 演奏凍結 SE
    $game_system.se_play($data_system.buzzer_se)
    return
  end
  # 演奏讀檔 SE
  $game_system.se_play($data_system.load_se)
  # 寫入存檔數據
  begin
    file = Zlib::GzipReader.open(filename)
    read_save_data(file)
  rescue
    # 演奏凍結 SE
    $game_system.se_play($data_system.buzzer_se)
    return
  end
  file.close
  # 還原 BGM、BGS
  $game_system.bgm_play($game_system.playing_bgm)
  $game_system.bgs_play($game_system.playing_bgs)
  # 刷新地圖 (執行並行事件)
  $game_map.update
  # 切換到地圖畫面
  $scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 取消時的處理
#--------------------------------------------------------------------------
def on_cancel
  # 演奏取消 SE
  $game_system.se_play($data_system.cancel_se)
  # 切換到標題畫面
  $scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 讀取存檔數據
#   file : 讀取用文件對像 (已經打開)
#--------------------------------------------------------------------------
def read_save_data(file)
 
$desc=Marshal.load(file) 
  # 讀取描繪存檔文件用的角色數據
  characters = Marshal.load(file)
  # 讀取測量遊戲時間用畫面計數
  Graphics.frame_count = Marshal.load(file)
  # 讀取校驗
  crcs = Marshal.load(file)
  # 讀取文檔字串
  strings = Marshal.load(file)
  # 校驗檢測
  key = SAVE_KEY
  strings.each_index do |i|
    key = Zlib.crc32(strings[i],key)
    unless crcs[i] == key
    file.close
    raise "file check error"
    return
    end
  end
  # 讀取各種遊戲對像
  $game_system = Marshal.load(Zlib::Inflate.inflate(strings[0]))
  $game_variables = Marshal.load(Zlib::Inflate.inflate(strings[1]))
  $game_self_switches = Marshal.load(Zlib::Inflate.inflate(strings[2]))
  $game_switches = Marshal.load(Zlib::Inflate.inflate(strings[3]))
  $game_troop = Marshal.load(Zlib::Inflate.inflate(strings[4]))
  $game_map = Marshal.load(Zlib::Inflate.inflate(strings[5]))
  $game_player = Marshal.load(Zlib::Inflate.inflate(strings[6]))
  $game_screen = Marshal.load(Zlib::Inflate.inflate(strings[7]))
  $game_actors = Marshal.load(Zlib::Inflate.inflate(strings[8]))
  $game_party = Marshal.load(Zlib::Inflate.inflate(strings[9]))
  $floorenemies = Marshal.load(Zlib::Inflate.inflate(strings[10]))
  $fledam = Marshal.load(Zlib::Inflate.inflate(strings[11]))
#  $data_enemies = Marshal.load(Zlib::Inflate.inflate(strings[12]))
 
  # 魔法編號與保存時有差異的情況下
  # (加入編輯器的編輯過的數據)
  if $game_system.magic_number != $data_system.magic_number
    # 重新裝載地圖
    $game_map.setup($game_map.map_id)
    $game_player.center($game_player.x, $game_player.y)
  end
  # 刷新同伴成員
  $game_party.refresh
end
end

#==============================================================================
# 自定義存檔菜單
#==============================================================================
#==============================================================================
# ■ Scene_Save
#------------------------------------------------------------------------------
#  處理存檔畫面的類。
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# ● 初始化對像
#--------------------------------------------------------------------------
def initialize()#save_max = SAVE_MAX)
  super("要保存到這個文件嗎?")#,"存入",save_max)
end
#--------------------------------------------------------------------------
# ● 確定時的處理
#--------------------------------------------------------------------------
def on_decision(filename)
  # 演奏存檔 SE
  $game_system.se_play($data_system.save_se)
  # 寫入存檔數據
  file = Zlib::GzipWriter.open(filename,9)
  write_save_data(file)
  file.close
  # 如果被事件調用
  if $game_temp.save_calling
    # 清除存檔調用標誌
    $game_temp.save_calling = false
    # 切換到地圖畫面
    $scene = Scene_Map.new
    return
  end
  # 切換到地圖畫面
  $scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 取消時的處理
#--------------------------------------------------------------------------
def on_cancel
  # 演奏取消 SE
  $game_system.se_play($data_system.cancel_se)
  # 如果被事件調用
  if $game_temp.save_calling
    # 清除存檔調用標誌
    $game_temp.save_calling = false
    # 切換到地圖畫面
    $scene = Scene_Map.new
    return
  end
  # 切換到地圖畫面
  $scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 寫入存檔數據
#   file : 寫入用文件對像 (已經打開)
#--------------------------------------------------------------------------
def write_save_data(file) 
  # 生成描繪存檔文件用的角色圖形
  characters = []
  for i in 0...$game_party.actors.size
    actor = $game_party.actors[i]
    characters.push([actor.character_name, actor.character_hue,actor.id])
  end
 
  if $game_variables[6]==1
    if $game_switches[36]
      $desc="普通    第 "+$game_variables[2].to_s+" 層"
    else
      $desc="普通    "+$game_variables[2].to_s
    end
  else
    if $game_switches[36]
      $desc="困難    第 "+$game_variables[2].to_s+" 層"
    else
      $desc="困難    "+$game_variables[2].to_s
    end
  end
 
  strings = []
 
  Marshal.dump($desc,file)#自己加的用來顯示難度和樓層的
 
  # 寫入描繪存檔文件用的角色數據
  Marshal.dump(characters,file)
  # 寫入測量遊戲時間用畫面計數
  Marshal.dump(Graphics.frame_count,file)
  # 增加 1 次存檔次數
  $game_system.save_count += 1
  # 保存魔法編號
  # (將編輯器保存的值以隨機值替換)
  $game_system.magic_number = $data_system.magic_number
 
  # 寫入各種遊戲對像
  #$game_switches[4]=true#樓層第一次刷新的開關打開以便讀檔後刷新
#R工程的開關4通常都不是「當前樓層第一次刷新」#不能一存檔就把開關4打開了,
#不然遊戲會出錯的
 
  strings.push(Zlib::Deflate.deflate(Marshal.dump($game_system)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($game_variables)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($game_self_switches)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($game_switches)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($game_troop)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($game_map)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($game_player)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($game_screen)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($game_actors)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($game_party)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($floorenemies)))
  strings.push(Zlib::Deflate.deflate(Marshal.dump($fledam)))
#  strings.push(Zlib::Deflate.deflate(Marshal.dump($data_enemies)))
 
 
  # 計算校驗值
  crcs = []
  key = SAVE_KEY
  strings.each do |i|
    key = Zlib.crc32(i,key)
    crcs.push(key)
  end
  Marshal.dump(crcs,file)
  Marshal.dump(strings,file)
end
end
#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
#  顯示存檔以及讀檔畫面、保存文件的窗口。
#==============================================================================
class Window_SaveFile < Window_Base
#--------------------------------------------------------------------------
# ● 初始化對像
#   file_index : 存檔文件的索引 (0~n)
#   filename   : 文件名
#--------------------------------------------------------------------------
def initialize(file_index, filename,viewport=nil)
  super(0, 64 + file_index % 4 * 104, 640, 104)
  self.contents = Bitmap.new(width - 32, height - 32)
  @file_index = file_index
  @filename = "Save/motaSave#{file_index + 1}.rxdata"
  @time_stamp = Time.at(0)
  @file_exist = FileTest.exist?(@filename)
  if @file_exist
    begin
    file = Zlib::GzipReader.open(filename)
    @time_stamp = file.mtime
   
    @desc=Marshal.load(file)
    @characters = Marshal.load(file)
    @frame_count = Marshal.load(file)
    @total_sec = @frame_count / Graphics.frame_rate
   
    file.close
    rescue
    @file_exist = false
    end
  end
 
  self.refresh
  @selected = false
end
end

3樓 巨大八爪鱼 2013-7-7 16:44
然後,自己把腳本裏面的密鑰改了。當然你實在不想改也行。現在以前的存檔因為密鑰和文件結構等問題,已經不能讀取了,下面詳細講解如何恢復以前的4個存檔。先不要移動和改名這4個存檔。(這個時候Scene_Title的讀檔部分也不要動,等存檔恢復了再改)
4樓 巨大八爪鱼 2013-7-7 16:45
把整個工程都複製一份,注意必須要複製一份。然後打開複製的那個工程。打開Scene_Title,把#--------------------------------------------------------------------------
  # ● 命令 : 繼續
  #--------------------------------------------------------------------------下面的$scene = Scene_Load.new(大概在157行上下)改成$scene = RINIMA.new。然後再新建一個腳本,內容:
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
#  存檔畫面及讀檔畫面的超級類。
#==============================================================================
class DASINI
  #--------------------------------------------------------------------------
  # ● 初始化對像
  #     help_text : 幫助窗口顯示的字符串
  #--------------------------------------------------------------------------
  def initialize(help_text)
    @help_text = help_text
  end
  #--------------------------------------------------------------------------
  # ● 主處理
  #--------------------------------------------------------------------------
  def main
    # 生成幫助窗口
    @help_window = Window_Help.new
    @help_window.set_text(@help_text)
    # 生成存檔文件窗口
    @savefile_windows = []
    for i in 0..3
      @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
    end
    # 選擇最後操作的文件
    @file_index = $game_temp.last_file_index
    @savefile_windows[@file_index].selected = true
    # 執行過渡
    Graphics.transition
    # 主循環
    loop do
      # 刷新遊戲畫面
      Graphics.update
      # 刷新輸入信息
      Input.update
      # 刷新畫面
      update
      # 如果畫面被切換的話就中斷循環
      if $scene != self
        break
      end
    end
    # 準備過渡
    Graphics.freeze
    # 釋放窗口
    @help_window.dispose
    for i in @savefile_windows
      i.dispose
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新畫面
  #--------------------------------------------------------------------------
  def update
    # 刷新窗口
    @help_window.update
    for i in @savefile_windows
      i.update
    end
    # 按下 C 鍵的情況下
    if Input.trigger?(Input::C)
      # 調用過程 on_decision (定義繼承目標)
      on_decision(make_filename(@file_index))
      $game_temp.last_file_index = @file_index
      return
    end
    # 按下 B 鍵的情況下
    if Input.trigger?(Input::B)
      # 調用過程 on_cancel (定義繼承目標)
      on_cancel
      return
    end
    # 按下方向鍵下的情況下
    if Input.repeat?(Input::DOWN)
      # 方向鍵下的按下狀態不是重複的情況下、
      # 並且光標的位置在 3 以前的情況下
      if Input.trigger?(Input::DOWN) or @file_index < 3
        # 演奏光標 SE
        $game_system.se_play($data_system.cursor_se)
        # 光標向下移動
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 1) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    # 按下方向鍵上的情況下
    if Input.repeat?(Input::UP)
      # 方向鍵上的按下狀態不是重複的情況下、
      # 並且光標的位置在 0 以後的情況下
      if Input.trigger?(Input::UP) or @file_index > 0
        # 演奏光標 SE
        $game_system.se_play($data_system.cursor_se)
        # 光標向上移動
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 3) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 生成文件名
  #     file_index : 文件名的索引 (0~3)
  #--------------------------------------------------------------------------
  def make_filename(file_index)
    return "Save#{file_index + 1}.rxdata"
  end
end
#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
#  處理讀檔畫面的類。
#==============================================================================
class RINIMA < DASINI
  #--------------------------------------------------------------------------
  # ● 初始化對像
  #--------------------------------------------------------------------------
  def initialize
    # 再生成臨時對像
    $game_temp = Game_Temp.new
    # 選擇存檔時間最新的文件
    $game_temp.last_file_index = 0
    latest_time = Time.at(0)
    for i in 0..3
      filename = make_filename(i)
      if FileTest.exist?(filename)
        file = File.open(filename, "r")
        if file.mtime > latest_time
          latest_time = file.mtime
          $game_temp.last_file_index = i
        end
        file.close
      end
    end
    super("你媽逼")
  end
  #--------------------------------------------------------------------------
  # ● 確定時的處理
  #--------------------------------------------------------------------------
  def on_decision(filename)
    # 文件不存在的情況下
    unless FileTest.exist?(filename)
      # 演奏凍結 SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    # 演奏讀檔 SE
    $game_system.se_play($data_system.load_se)
    # 寫入存檔數據
    file = File.open(filename, "rb")
    read_save_data(file)
    file.close
    # 還原 BGM、BGS
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    # 刷新地圖 (執行並行事件)
    $game_map.update
    # 切換到地圖畫面
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # ● 取消時的處理
  #--------------------------------------------------------------------------
  def on_cancel
    # 演奏取消 SE
    $game_system.se_play($data_system.cancel_se)
    # 切換到標題畫面
    $scene = Scene_Title.new
  end
  #--------------------------------------------------------------------------
  # ● 讀取存檔數據
  #     file : 讀取用文件對像 (已經打開)
  #--------------------------------------------------------------------------
  def read_save_data(file)
    # 讀取描繪存檔文件用的角色數據
    characters = Marshal.load(file)
    # 讀取測量遊戲時間用畫面計數
    Graphics.frame_count = Marshal.load(file)
    # 讀取各種遊戲對像
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    # 魔法編號與保存時有差異的情況下
    # (加入編輯器的編輯過的數據)
    if $game_system.magic_number != $data_system.magic_number
      # 重新裝載地圖
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    # 刷新同伴成員
    $game_party.refresh
  end
end

5樓 巨大八爪鱼 2013-7-7 16:45
在複製的工程中建立save文件夾。
運行遊戲,把4個存檔中的每個存檔都讀檔(讀檔畫面寫的是「你媽逼」,把1-4都讀一遍,雖然看不到有文件顯示),然後再存檔。
這樣save文件夾就有了4個新的存檔。
把這4個存檔拿出來,刪掉複製的工程。再把這4個存檔複製到原工程的save文件夾中。打開原工程,
標題畫面的讀檔部分還要改。找到Scene_Title的47-52行,把
@continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end
改成
@continue_enabled = false
    for i in 0..999
      if FileTest.exist?("Save/motaSave#{i+1}.rxdata")
        @continue_enabled = true
        break
      end
    end

然後運行遊戲就行了。

6樓 巨大八爪鱼 2013-7-7 16:46
————————本教程完畢

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
 
 
©2010-2024 Purasbar [手機版] [桌面版]
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。