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

Project1

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

[有事请教] 【存档扩展出错】脚本冲突

[复制链接]

Lv2.观梦者

梦石
0
星屑
386
在线时间
56 小时
注册时间
2017-5-16
帖子
20
跳转到指定楼层
1
发表于 2024-7-17 22:14:51 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 blueppe 于 2024-7-17 22:14 编辑

如题【存档扩展出错】
使用的【存档扩展脚本】来自:
https://rpg.blue/thread-403346-1-1.html


自己的游戏保存第5个位置后就会显示出错:
脚本Scene_File 的第29行 发生了 NoMethodError。
undefined method "selected=" for nil:Nil Class

研究了下发现是加了【半透明背景脚本】后会才导致的脚本冲突

所以想问看有没有太太能帮忙改改脚本?我看不出哪里冲突T_T

以下是半透明背景脚本:
RUBY 代码复制
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================
  4. #==============================================================================
  5. # ■ Window_Base
  6. #==============================================================================
  7. class Window_Base < Window
  8.   alias xrxs_mp7_initialize initialize
  9.   def initialize(x, y, width, height)
  10.     xrxs_mp7_initialize(x, y, width, height)
  11.     if $scene.is_a?(Scene_Menu) or
  12.        $scene.is_a?(Scene_Item) or  
  13.        $scene.is_a?(Scene_Skill) or  
  14.        $scene.is_a?(Scene_Equip) or  
  15.        $scene.is_a?(Scene_Status) or  
  16.        $scene.is_a?(Scene_Save) or  
  17.        $scene.is_a?(Scene_End)
  18.       self.back_opacity = 160  #————这个数值可调,为透明程度
  19.     end
  20.   end
  21. end
  22. module XRXS_MP7_Module
  23.   def create_spriteset
  24.     @spriteset = Spriteset_Map.new
  25.   end
  26.   def dispose_spriteset
  27.     @spriteset.dispose
  28.   end
  29. end
  30. class Scene_Menu
  31.   include XRXS_MP7_Module
  32.   alias xrxs_mp7_main main
  33.   def main
  34.     create_spriteset
  35.     xrxs_mp7_main
  36.     dispose_spriteset
  37.   end
  38. end
  39. class Scene_Item
  40.   include XRXS_MP7_Module
  41.   alias xrxs_mp7_main main
  42.   def main
  43.     create_spriteset
  44.     xrxs_mp7_main
  45.     dispose_spriteset
  46.   end
  47. end
  48. class Scene_Skill
  49.   include XRXS_MP7_Module
  50.   alias xrxs_mp7_main main
  51.   def main
  52.     create_spriteset
  53.     xrxs_mp7_main
  54.     dispose_spriteset
  55.   end
  56. end
  57. class Scene_Equip
  58.   include XRXS_MP7_Module
  59.   alias xrxs_mp7_main main
  60.   def main
  61.     create_spriteset
  62.     xrxs_mp7_main
  63.     dispose_spriteset
  64.   end
  65. end
  66. class Scene_Status
  67.   include XRXS_MP7_Module
  68.   alias xrxs_mp7_main main
  69.   def main
  70.     create_spriteset
  71.     xrxs_mp7_main
  72.     dispose_spriteset
  73.   end
  74. end
  75. class Scene_Save
  76.   include XRXS_MP7_Module
  77.   alias xrxs_mp7_main main
  78.   def main
  79.     create_spriteset
  80.     xrxs_mp7_main
  81.     dispose_spriteset
  82.   end
  83. end
  84. class Scene_End
  85.   include XRXS_MP7_Module
  86.   alias xrxs_mp7_main main
  87.   def main
  88.     create_spriteset
  89.     xrxs_mp7_main
  90.     dispose_spriteset
  91.   end
  92. end
  93. #==============================================================================
  94. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  95. #==============================================================================




以下是【半透明背景脚本】:

RUBY 代码复制
  1. #==============================================================================
  2. # ■ 存档位真·无限扩展 v2.1 by SailCat
  3. #------------------------------------------------------------------------------
  4. #  方法:插入到Main之前使用。
  5. #   版本:v2.1 (Build 171011)
  6. #   效果:存档位真·无限扩展,不需要配置,系统自动检测根据存档逐一扩展
  7. #   冲突:和其他存档扩展脚本冲突
  8. #   操作:上下翻1,左右翻4,Ctrl+上下翻16,Ctrl+左右翻64,LR翻256,Ctrl+LR头尾
  9. #==============================================================================
  10.  
  11. class Scene_File
  12.   #--------------------------------------------------------------------------
  13.   # ● 追加定义
  14.   #--------------------------------------------------------------------------
  15.   attr_reader  :top_index # 首项 索引值
  16.   unless method_defined? :sailcat_initialize
  17.     alias sailcat_initialize initialize
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 初始化对像
  21.   #     help_text : 帮助窗口显示的字符串
  22.   #--------------------------------------------------------------------------
  23.   def initialize(help_text)
  24.     sailcat_initialize(help_text)
  25.     @file_count ||= save_count
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 设置首项,重绘首项之后的4个窗口
  29.   #     index : 新的首项
  30.   #--------------------------------------------------------------------------
  31.   def top_index=(index)
  32.     index = [0, [index / 4 * 4, @file_count - 1].min].max
  33.     if @top_index != index
  34.       @top_index = index
  35.       redraw_windows
  36.     end
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 主处理
  40.   #--------------------------------------------------------------------------
  41.   def main
  42.     # 生成帮助窗口
  43.     @help_window = Window_Help.new
  44.     @help_window.set_text(@help_text)
  45.     # 选择最后操作的文件
  46.     @file_index = [@file_count - 1, $game_temp.last_file_index].min
  47.     # 只刷新需要显示的窗口
  48.     self.top_index = @file_index
  49.     @savefile_windows[@file_index % 4].selected = true
  50.     # 执行过渡
  51.     Graphics.transition
  52.     # 主循环
  53.     loop do
  54.       # 刷新游戏画面
  55.       Graphics.update
  56.       # 刷新输入信息
  57.       Input.update
  58.       # 刷新画面
  59.       update
  60.       # 如果画面被切换的话就中断循环
  61.       if $scene != self
  62.         break
  63.       end
  64.     end
  65.     # 准备过渡
  66.     Graphics.freeze
  67.     # 释放窗口
  68.     @help_window.dispose
  69.     for i in @savefile_windows
  70.       i.dispose
  71.     end
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # ● 刷新画面
  75.   #--------------------------------------------------------------------------
  76.   def update
  77.     # 刷新窗口
  78.     @help_window.update
  79.     for i in @savefile_windows[0..3]
  80.       i.update
  81.     end
  82.     # 按下 C 键的情况下
  83.     if Input.trigger?(Input::C)
  84.       # 调用过程 on_decision (定义继承目标)
  85.       on_decision(make_filename(@file_index))
  86.       $game_temp.last_file_index = @file_index
  87.       return
  88.     end
  89.     # 按下 B 键的情况下
  90.     if Input.trigger?(Input::B)
  91.       # 调用过程 on_cancel (定义继承目标)
  92.       on_cancel
  93.       return
  94.     end
  95.     # 按下下方向键的情况下
  96.     if Input.repeat?(Input::DOWN)
  97.       move_index(Input.press?(Input::CTRL) ? 16 : 1)
  98.       return
  99.     end
  100.     # 按下上方向键的情况下
  101.     if Input.repeat?(Input::UP)
  102.       move_index(Input.press?(Input::CTRL) ? -16 : -1)
  103.       return
  104.     end
  105.     # 按下左方向键的情况下
  106.     if Input.repeat?(Input::LEFT)
  107.       move_index(Input.press?(Input::CTRL) ? -64 : -4)
  108.       return
  109.     end
  110.     # 按下右方向键的情况下
  111.     if Input.repeat?(Input::RIGHT)
  112.       move_index(Input.press?(Input::CTRL) ? 64 : 4)
  113.       return
  114.     end
  115.     # 按下 R 键的情况下
  116.     if Input.trigger?(Input::R)
  117.       Input.press?(Input::CTRL) ? set_index(-1) : move_index(256)
  118.       return
  119.     end
  120.     # 按下 L 键的情况下
  121.     if Input.trigger?(Input::L)
  122.       Input.press?(Input::CTRL) ? set_index(0) : move_index(-256)
  123.       return
  124.     end
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 生成文件名
  128.   #     file_index : 文件名的索引 (0~3)
  129.   #--------------------------------------------------------------------------
  130.   def make_filename(file_index)
  131.     return "Save#{file_index + 1}.rxdata"
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 移动光标
  135.   #     distance : 移动的距离
  136.   #--------------------------------------------------------------------------
  137.   def move_index(distance)
  138.     if @file_index == 0 and distance < 0
  139.       set_index(-1)
  140.     elsif @file_index == @file_count - 1 and distance > 0
  141.       set_index(0)
  142.     else
  143.       set_index([0, [@file_index + distance, @file_count - 1].min].max)
  144.     end
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ● 设置光标位置
  148.   #     new_index : 新光标位置
  149.   #--------------------------------------------------------------------------
  150.   def set_index(new_index)
  151.     new_index += @file_count if new_index < 0
  152.     # 演奏光标 SE
  153.     $game_system.se_play($data_system.cursor_se)
  154.     # 光标移动到新位置
  155.     @savefile_windows[@file_index % 4].selected = false
  156.     @file_index = new_index
  157.     self.top_index = new_index
  158.     @savefile_windows[@file_index % 4].selected = true
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● 检测存档数目
  162.   #--------------------------------------------------------------------------
  163.   def save_count
  164.     i = 0
  165.     while FileTest.exists?(make_filename(i))
  166.       i += 1
  167.     end
  168.     return self.is_a?(Scene_Save) ? i + 1 : i
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● 重绘存档文件窗口
  172.   #--------------------------------------------------------------------------
  173.   def redraw_windows
  174.     # 生成存档文件窗口
  175.     @savefile_windows.each { |i| i.dispose } unless @savefile_windows == nil
  176.     @savefile_windows = []
  177.     for i in @top_index...[@top_index + 4, @file_count].min
  178.       filename = make_filename(i)
  179.       window = Window_SaveFile.new(i, filename)
  180.       window.y = i % 4 * 104 + 64
  181.       @savefile_windows.push(window)
  182.     end
  183.     (4 - @savefile_windows.size).times do |i|
  184.       window = Window_Base.new(0, 376 - i * 104, 640, 104)
  185.       window.opacity = window.back_opacity = 128
  186.       @savefile_windows.push(window)
  187.     end
  188.   end
  189. end
  190.  
  191. class Scene_Load < Scene_File
  192.   #--------------------------------------------------------------------------
  193.   # ● 初始化对像
  194.   #--------------------------------------------------------------------------
  195.   def initialize
  196.     # 再生成临时对像
  197.     $game_temp = Game_Temp.new
  198.     # 选择存档时间最新的文件
  199.     $game_temp.last_file_index = 0
  200.     latest_time = Time.at(0)
  201.     @file_count = save_count
  202.     for i in 0...@file_count
  203.       File.open(make_filename(i), "r") do |f|
  204.         if f.mtime > latest_time
  205.           latest_time = f.mtime
  206.           $game_temp.last_file_index = i
  207.         end
  208.       end
  209.     end
  210.     super("要载入哪个文件?")
  211.   end
  212. end



00error.png (22.08 KB, 下载次数: 4)

00error.png

Lv2.观梦者

梦石
0
星屑
386
在线时间
56 小时
注册时间
2017-5-16
帖子
20
2
 楼主| 发表于 2024-7-17 22:19:00 | 只看该作者
或者说有没有其他更简易的扩展存档的脚本吗?其实理想中差不多8个存档位置就可以了...找了全网只看到这个脚本比较完整

点评

还有一点就是 我觉得 可能透明度脚本识别的名称 和这个扩展存档名称的脚本名字对应不上  发表于 2024-8-22 17:04
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
14355
在线时间
2123 小时
注册时间
2016-9-20
帖子
856
3
发表于 2024-7-18 12:56:05 | 只看该作者
这个半透明背景脚本好像有BUG , 建议不用,脚本好像是在进入其他副场景(Scene)比如装备页面时会生成一个Spriteset_Map.new 然后在进入其他场景,我理解同时进行容易冲突
我发的贴子大多未经整理是草稿抱歉
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1303
在线时间
173 小时
注册时间
2019-10-4
帖子
239
4
发表于 2024-8-22 17:03:26 | 只看该作者
两种方法 调换 1.调换透明度脚本位置  或者自己手动每个窗口 160 添加透明度.opacity = 235  2.二 Scene_File存档 Scene_Save存档 Scene_Load存档 这三个里面的脚本自行添加 8个存档窗口即可 1..3 1..8具体怎么加我忘了 很久之前的事情了 不过这个方法合适脚本语法基础好点的人
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
625
在线时间
36 小时
注册时间
2024-1-28
帖子
9
5
发表于 2024-8-23 22:37:06 | 只看该作者
试试把半透明背景脚本里关于存档的部分全都注释掉?
半透明背景脚本第16行以及75~83行,全都注释掉之后脚本运行就不冲突了(虽然代价是存档页面无法半透明化……)
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-8 10:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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