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

Project1

 找回密码
 注册会员
搜索
查看: 3101|回复: 7

[已经解决] 求助::无法保存存档

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
53 小时
注册时间
2016-2-10
帖子
21
发表于 2016-3-19 15:34:52 | 显示全部楼层 |阅读模式

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

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

x
脚本有点多,然后保存的时候报出错误
换成默认的保存脚本也一样。。。。
QQ图片20160319153654.png
a .png
出事的地方
    $game_system.save_count += 1
    $game_system.version_id = $data_system.version_id

Lv1.梦旅人

梦石
0
星屑
50
在线时间
53 小时
注册时间
2016-2-10
帖子
21
 楼主| 发表于 2016-3-19 15:39:38 | 显示全部楼层
本帖最后由 Rivendell 于 2016-3-19 20:09 编辑

#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
#  This class performs the save and load screen processing.
#==============================================================================
module FATE_SCENE_FILE
  EXMNU_INCSF_FILE_MAX = 10
  EXMNU_INCSF_WINDOW_HEIGHT = 120
  WY = 22
  HEIGHT = 60
  TIME_NAME = "游戏时间"
  MAP_NAME = "所在地 "
  SAVE_CONFIRM = "确定保存到这个位置上吗?"
  LORD_CONFIRM = "确定读取这个位置吗?"
end

class Scene_File < Scene_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     saving     : save flag (if false, load screen)
  #     from_title : flag: it was called from "Continue" on the title screen
  #     from_event : flag: it was called from the "Call Save Screen" event
  #--------------------------------------------------------------------------
  def initialize(saving, from_title, from_event)
    @saving = saving
    @from_title = from_title
    @from_event = from_event
    @menu_effect = []
  end
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    @menu_file = false
    $game_temp.mode = 0
    if $last_scene.is_a?(Scene_Menu)
      @menu_file = true
      $game_temp.mode = 1
    end
    @file_max = FATE_SCENE_FILE::EXMNU_INCSF_FILE_MAX
    create_menubackground
    create_command_window
    @help_window = Window_Help.new
    if @menu_file == true
      @help_window.opacity = 0
      @help_ex_window = Window_SaveHelpEx.new(-216, -16, 576, 448)
      @help_ex_window.opacity = 0
      #@help_ex_window.z = 999
      @back_sprite = Sprite.new
      @back_sprite.bitmap = Cache.menu("MenuSaveBack")
    end
    create_savefile_windows
    if @saving
      @index = $game_temp.last_file_index
      @help_window.set_text(Vocab::SaveMessage)
    else
      @index = self.latest_file_index
      @help_window.set_text(Vocab::LoadMessage)
    end
    @savefile_windows[@index].selected = true
    wh = FATE_SCENE_FILE::EXMNU_INCSF_WINDOW_HEIGHT
    adj = (416 - @help_window.height) % wh
    @help_window.height += adj
    @page_file_max = ((416 - @help_window.height) / wh).truncate
    for i in 0...@file_max
      window = @savefile_windows
      if @index > @page_file_max - 1
        if @index < @file_max - @page_file_max - 1
          @top_row = @index
          window.y -= @index * window.height
        elsif @index >= @file_max - @page_file_max
          @top_row = @file_max - @page_file_max
          window.y -= (@file_max - @page_file_max) * window.height
        else
          @top_row = @index
          window.y -= @index * window.height
        end
      end
      window.y += adj
      window.visible = (window.y >= @help_window.height and
      window.y < @help_window.height + @page_file_max * window.height)
    end
    if @menu_file == true
      for i in 1..3
        @menu_effect = Plane.new
        @menu_effect.bitmap = Cache.menu("MenuEffect#{i}")
        @menu_effect.z = -3
        @menu_effect.opacity = 224
      end
    end
  end
  def create_menubackground
    if @menu_file == true
      @menuback = Sprite.new
      @menuback.bitmap = Cache.menu(FATE_SCENE::MENU_BACK)
      @menuback.opacity = 224
      @menuback.z = -4
    end
    @menuback_sprite = Sprite.new
    @menuback_sprite.bitmap = $game_temp.background_bitmap
    @menuback_sprite.z = -5
    update_menu_background
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @menuback.dispose if @menu_file == true
    @menuback_sprite.dispose
    @command_window.dispose
    @help_window.dispose
    dispose_item_windows
    if @menu_file == true
      @help_ex_window.dispose
      @back_sprite.bitmap.dispose
      @back_sprite.dispose
      for i in 1..3
        @menu_effect.dispose
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Return to Original Screen
  #--------------------------------------------------------------------------
  def return_scene
    if @from_title
      $scene = Scene_Title.new
    elsif @from_event
      $scene = Scene_Map.new
    elsif @saving
      $scene = Scene_Menu.new(6)
    else
      $scene = Scene_Menu.new(6)
     end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if @menu_file == true
      @menu_effect[1].oy += 3
      @menu_effect[2].oy += 1
    end
    update_menu_background
    @help_window.update
    if @menu_file == true
      @help_window.slide(0, @help_window.y)
      @help_window.contents_opacity += 16 if @help_window.contents_opacity < 255
      @help_ex_window.slide(-16, -16)
      if Input.dir4 != 0
        @help_window.x = -80
        @help_window.contents_opacity = 0
      end
    end
    unless @command_window.active
      update_savefile_windows
      update_savefile_selection
    end
    if @command_window.active
      @command_window.update
      update_fileconfirm_command_selection
    end
  end
  #--------------------------------------------------------------------------
  # ● 確認コマンドウィンドウの作成
  #--------------------------------------------------------------------------
  def create_command_window
    s1 = "是"
    s2 = "否"
    $game_temp.mode = 2 if @menu_file == true
    @command_window = Window_Command.new(160, [s1, s2])
    @command_window.x = 544 / 2 - @command_window.width / 2
    @command_window.y = 416 / 2 - @command_window.height / 2
    @command_window.z = 99999
    @command_window.index = 0
    @command_window.active = false
    @command_window.openness = 0
    $game_temp.mode = 1 if @menu_file == true
  end
  #--------------------------------------------------------------------------
  # * Create Save File Window
  #--------------------------------------------------------------------------
  def create_savefile_windows
    @top_row = 0
    @savefile_windows = []
    for i in 0...@file_max
      @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
    end
  end
  #--------------------------------------------------------------------------
  # * Dispose of Save File Window
  #--------------------------------------------------------------------------
  def dispose_item_windows
    for window in @savefile_windows
      window.dispose
    end
  end
  #--------------------------------------------------------------------------
  # * Update Save File Window
  #--------------------------------------------------------------------------
  def update_savefile_windows
    for window in @savefile_windows
      window.update
    end
  end
  #--------------------------------------------------------------------------
  # * Update Save File Selection
  #--------------------------------------------------------------------------
  def update_savefile_selection
    if Input.trigger?(Input::C)
      if @saving
        Sound.play_decision
        start_fileconfirm_command_selection
      else
        if @savefile_windows[@index].file_exist
          Sound.play_decision
          start_fileconfirm_command_selection
        else
          Sound.play_buzzer
          return
        end
      end
    elsif Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    else
      last_index = @index
      if Input.repeat?(Input::DOWN)
        cursor_down(Input.trigger?(Input::DOWN))
      end
      if Input.repeat?(Input::UP)
        cursor_up(Input.trigger?(Input::UP))
      end
      if @index != last_index
        Sound.play_cursor
        @savefile_windows[last_index].selected = false
        @savefile_windows[@index].selected = true
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● ファイル確認コマンド選択の開始
  #--------------------------------------------------------------------------
  def start_fileconfirm_command_selection
    Input.update
    @command_window.active = true
    if @saving
      @help_window.set_text(FATE_SCENE_FILE::SAVE_CONFIRM)
    else
      @help_window.set_text(FATE_SCENE_FILE::LORD_CONFIRM)
    end
    begin
      @command_window.update
      Graphics.update
      @command_window.openness += 40
    end until @command_window.openness == 255
  end
  #--------------------------------------------------------------------------
  # ● ファイル確認コマンド選択の終了
  #--------------------------------------------------------------------------
  def end_fileconfirm_command_selection
    @command_window.active = false
    begin
      @command_window.update
      Graphics.update
      @command_window.openness -= 40
    end until @command_window.openness == 0
    @command_window.index = 0
    if @saving
      @help_window.set_text(Vocab::SaveMessage)
    else
      @help_window.set_text(Vocab::LoadMessage)
    end
  end
  #--------------------------------------------------------------------------
  # ● ファイル確認コマンドの更新
  #--------------------------------------------------------------------------
  def update_fileconfirm_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      end_fileconfirm_command_selection
    elsif Input.trigger?(Input::C)
      case @command_window.index
      when 0
        determine_savefile
      when 1
        Sound.play_cancel
        end_fileconfirm_command_selection
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Confirm Save File
  #--------------------------------------------------------------------------
  def determine_savefile
    if @saving
      Sound.play_save
      do_save
    else
      if @savefile_windows[@index].file_exist
        Sound.play_load
        do_load
      else
        Sound.play_buzzer
        return
      end
    end
    $game_temp.last_file_index = @index
  end
  #--------------------------------------------------------------------------
  # * Move cursor down
  #     wrap : Wraparound allowed
  #--------------------------------------------------------------------------
  def cursor_down(wrap)
    if @index < @file_max - 1 or wrap
      @index = (@index + 1) % @file_max
      for i in 0...@file_max
        window = @savefile_windows
        if @index == 0
          @top_row = 0
          window.y = @help_window.height + i % @file_max * window.height
        elsif @index - @top_row > @page_file_max - 1
          window.y -= window.height
        end
        window.visible = (window.y >= @help_window.height and
          window.y < @help_window.height + @page_file_max * window.height)
      end
      if @index - @top_row > @page_file_max - 1
        @top_row += 1
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Move cursor up
  #     wrap : Wraparound allowed
  #--------------------------------------------------------------------------
  def cursor_up(wrap)
    if @index > 0 or wrap
      @index = (@index - 1 + @file_max) % @file_max
      for i in 0...@file_max
        window = @savefile_windows
        if @index == @file_max - 1
          @top_row = @file_max - @page_file_max
          window.y = @help_window.height + i % @file_max * window.height
          window.y -= (@file_max - @page_file_max) * window.height
        elsif @index - @top_row < 0
          window.y += window.height
        end
        window.visible = (window.y >= @help_window.height and
          window.y < @help_window.height + @page_file_max * window.height)
      end
      if @index - @top_row < 0
        @top_row -= 1
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Create Filename
  #     file_index : save file index (0-3)
  #--------------------------------------------------------------------------
  def make_filename(file_index)
    return FATE::SaveFolder+(file_index + 1).to_s+FATE::SaveFileExt
  end
  #--------------------------------------------------------------------------
  # * Select File With Newest Timestamp
  #--------------------------------------------------------------------------
  def latest_file_index
    index = 0
    latest_time = Time.at(0)
    for i in 0...@savefile_windows.size
      if @savefile_windows.time_stamp > latest_time
        latest_time = @savefile_windows.time_stamp
        index = i
      end
    end
    return index
  end
  #--------------------------------------------------------------------------
  # * Execute Save
  #--------------------------------------------------------------------------
  def do_save
    file = File.open(@savefile_windows[@index].filename, "wb")
    write_save_data(file)
    file.close
    return_scene
  end
  #--------------------------------------------------------------------------
  # * Execute Load
  #--------------------------------------------------------------------------
  def do_load
    file = File.open(@savefile_windows[@index].filename, "rb")
    read_save_data(file)
    file.close
    $scene = Scene_Map.new
    RPG::BGM.fade(1500)
    Graphics.fadeout(60)
    Graphics.wait(40)
    @last_bgm.play
    @last_bgs.play
  end
  #--------------------------------------------------------------------------
  # * Write Save Data
  #     file : write file object (opened)
  #--------------------------------------------------------------------------
  def write_save_data(file)
    map_info = load_data("Data/MapInfos.rvdata")
    map_info = map_info[$game_map.map_id]
    map_info = map_info.name
    n = map_info.split('')
    t = ""
    for i in 0...n.size
      break if n == "#"
      t += n
    end
    map_info = t

    characters = []
    face = []
    for actor in $game_party.members
      characters.push([actor.character_name, actor.character_index])
      face.push([actor.face_name, actor.face_index])
    end
    $game_system.save_count += 1
    $game_system.version_id = $data_system.version_id
    @last_bgm = RPG::BGM::last
    @last_bgs = RPG::BGS::last
    Marshal.dump(map_info,             file)
    Marshal.dump(characters,           file)
    Marshal.dump(face,                 file)
    Marshal.dump(Graphics.frame_count, file)
    Marshal.dump(@last_bgm,            file)
    Marshal.dump(@last_bgs,            file)
    Marshal.dump($game_system,         file)
    Marshal.dump($game_message,        file)
    Marshal.dump($game_switches,       file)
    Marshal.dump($game_variables,      file)
    Marshal.dump($game_self_switches,  file)
    Marshal.dump($game_actors,         file)
    Marshal.dump($game_party,          file)
    Marshal.dump($game_troop,          file)
    Marshal.dump($game_map,            file)
    Marshal.dump($game_player,         file)
  end
  #--------------------------------------------------------------------------
  # * Read Save Data
  #     file : file object for reading (opened)
  #--------------------------------------------------------------------------
  def read_save_data(file)
    map_info             = Marshal.load(file)
    characters           = Marshal.load(file)
    face                 = Marshal.load(file)
    Graphics.frame_count = Marshal.load(file)
    @last_bgm            = Marshal.load(file)
    @last_bgs            = Marshal.load(file)
    $game_system         = Marshal.load(file)
    $game_message        = Marshal.load(file)
    $game_switches       = Marshal.load(file)
    $game_variables      = Marshal.load(file)
    $game_self_switches  = 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.version_id != $data_system.version_id
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    $game_switches[280] = true
  end
end

附上脚本
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
53 小时
注册时间
2016-2-10
帖子
21
 楼主| 发表于 2016-3-19 16:51:13 | 显示全部楼层
话说6R已经没人了么
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
20915
在线时间
9331 小时
注册时间
2012-6-19
帖子
7105

开拓者短篇九导演组冠军

发表于 2016-3-19 18:42:01 | 显示全部楼层
你在事件指令中获取一下游戏的存档次数,试试看是否会报错

评分

参与人数 1星屑 +60 收起 理由
正太君 + 60 塞糖

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1343
在线时间
1295 小时
注册时间
2012-8-4
帖子
749
发表于 2016-3-19 19:36:01 | 显示全部楼层
本帖最后由 夜狠简单 于 2016-3-19 19:52 编辑

$game_temp.mode是什么,这个脚本运行到这就开始报错,别提后面。

评分

参与人数 1星屑 +60 收起 理由
正太君 + 60 塞糖

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
53 小时
注册时间
2016-2-10
帖子
21
 楼主| 发表于 2016-3-19 20:51:25 | 显示全部楼层
喵呜喵5 发表于 2016-3-19 18:42
你在事件指令中获取一下游戏的存档次数,试试看是否会报错

没有,返回了nil
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
53 小时
注册时间
2016-2-10
帖子
21
 楼主| 发表于 2016-3-19 20:52:09 | 显示全部楼层
夜狠简单 发表于 2016-3-19 19:36
$game_temp.mode是什么,这个脚本运行到这就开始报错,别提后面。

在另一个脚本里,$game_temp.mode = 0

点评

你新建一个脚本,把这个存档用到的脚本放进去,我帮你调看看  发表于 2016-3-19 21:13
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
20915
在线时间
9331 小时
注册时间
2012-6-19
帖子
7105

开拓者短篇九导演组冠军

发表于 2016-3-19 21:29:41 | 显示全部楼层
Rivendell 发表于 2016-3-19 20:51
没有,返回了nil

什么叫 “没有,返回了 nil” ?

返回了 nil 就是报错了啊

点评

已解决,感谢 :)  发表于 2016-3-19 23:06
nil+=1 这样不能用的,建议你判断$game_system.save_count==nil赋值  发表于 2016-3-19 22:19
。。。我手动弄了$game_system.save_count =0 正常保存  发表于 2016-3-19 22:13
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-18 14:05

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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