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

Project1

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

[已经解决] 选项扩展脚本导致的无法存档是怎回事呢??

[复制链接]

Lv5.捕梦者

梦石
0
星屑
24307
在线时间
5050 小时
注册时间
2016-3-8
帖子
1619
跳转到指定楼层
1
发表于 2021-3-4 22:41:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
180星屑
本帖最后由 alexncf125 于 2021-4-1 20:34 编辑

插入脚本后, 还是能存档的...
但一用"显示选项"事件指令, 就会变得不能存档了...
这BUG是怎么一回事呢   
RUBY 代码复制
  1. #===============================================================================
  2. # Zetu Engine V: Choices Extention
  3. #     by Zetu
  4. #     --- Created: 12/30/2014
  5. #     --- Updated: 01/06/2015 v1.02
  6. #-------------------------------------------------------------------------------
  7. # Instructions: Place special commands inside Display Choices.
  8. # [mode=?]
  9. #   Option: H
  10. #       Displays choices horizontally
  11. #   Option: C
  12. #       Centers choice display
  13. #   Option: X
  14. #       Shows no back window while displayed
  15. #   Option: F
  16. #       Fixes location of first selection
  17. #   Option: U, Adds F, H, C
  18. #       Centers options on item, rather than window
  19. #   Option: R, Ignores H, U
  20. #       Counts as X. Display choices in a circular fasion.
  21. # [img=?]
  22. #   Displays an image with the specified filename as an option. Option: I
  23. # [switch=?]
  24. #   Only shows if specified switch ID is ON.
  25. #-------------------------------------------------------------------------------
  26. # Changelog:
  27. #   v1.01
  28. #     * Fixed bug causing normal text to not adapt window size.
  29. #         < Reported by ArbitraryGuy >
  30. #   v1.02
  31. #     + Added [icon=?]
  32. #     + Added [switch=?]
  33. #     + Added F mode option.
  34. #     + Added U mode option.
  35. #     + Added Feature to combine Choice Box Dialogs.
  36. #===============================================================================
  37.  
  38. class Window_Command < Window_Selectable
  39.  
  40.   #=============================================================================
  41.   # Create Objects
  42.   #-----------------------------------------------------------------------------
  43.   alias :zev_choice_add_command :add_command
  44.   def add_command(name, symbol, enabled = true, ext = nil)
  45.     command = name.dup
  46.     if command =~ /\[mode\=(.+?)\]/i
  47.       modes = $1.lstrip.rstrip.upcase
  48.       modes.split(//).each do |m|
  49.         @modes |= [m]
  50.         case m
  51.         when "U"
  52.           @modes |= ["H", "C", "F"]
  53.         end
  54.       end
  55.       command.gsub!(/\[mode\=.+?\]/i, "")
  56.     end
  57.     if name =~ /\[img\=(.+?)\]/i
  58.       @modes |= ["I"]
  59.       filename = $1.lstrip.rstrip
  60.       filename = $game_variables[$1.to_f.to_i].lstrip.rstrip if $1.to_f.to_i > 0
  61.       width    = Cache.picture(filename).width
  62.       height   = Cache.picture(filename).height
  63.       @list.push({:name=>command, :symbol=>symbol, :enabled=>enabled, :ext=>ext,
  64.       :zev_ext=>:image, :filename=>filename, :width=>width, :height=>height})
  65.     else
  66.       zev_choice_add_command(command, symbol, enabled, ext)
  67.     end
  68.   end
  69.  
  70.   #=============================================================================
  71.   # Clear
  72.   #-----------------------------------------------------------------------------
  73.   alias :zev_stabs_clear_command_list :clear_command_list
  74.   def clear_command_list
  75.     @modes = []
  76.     zev_stabs_clear_command_list
  77.   end
  78.  
  79.   #=============================================================================
  80.   # Conditions
  81.   #-----------------------------------------------------------------------------
  82.   def mode_include?(s)
  83.     return false unless @modes
  84.     return true if @modes.include?(s)
  85.     return false
  86.   end
  87.  
  88. end
  89.  
  90. class Window_ChoiceList < Window_Command
  91.  
  92.   alias :zev_sbp_start :start
  93.   def start
  94.     zev_sbp_start
  95.     update_placement
  96.     select(0)
  97.   end
  98.  
  99.   #=============================================================================
  100.   # Update
  101.   #-----------------------------------------------------------------------------
  102.   def update
  103.     super
  104.     update_xy(self.index)
  105.   end
  106.  
  107.   def update_placement
  108.     update_size
  109.     update_xy
  110.     self.opacity = mode_include?("X") ? 0 : 255
  111.   end
  112.  
  113.   def update_size
  114.     self.width  = contents_width + padding * 2
  115.     self.height = contents_height + padding * 2
  116.   end
  117.  
  118.   def update_xy(index = 0)
  119.     self.x = Graphics.width - width
  120.     if @message_window.y >= Graphics.height / 2
  121.       self.y = @message_window.y - height
  122.     else
  123.       if mode_include?("C")
  124.         self.y = Graphics.height + @message_window.y + @message_window.height - self.height
  125.       else
  126.         self.y = @message_window.y + @message_window.height
  127.       end
  128.     end
  129.     if mode_include?("C")
  130.       self.x /= 2
  131.       self.y /= 2
  132.     end
  133.     if mode_include?("U")
  134.       self.x = (Graphics.width - item_rect(index).width) / 2
  135.     end
  136.     if mode_include?("F")
  137.       if mode_include?("H")
  138.         self.x -= get_special_x(index)
  139.       else
  140.         self.y -= get_special_y(index)
  141.       end
  142.     end
  143.   end
  144.  
  145.   def update_padding_bottom
  146.     if mode_include?("I")
  147.       self.padding_bottom = 0
  148.     else
  149.       super
  150.     end
  151.   end
  152.  
  153.   def ensure_cursor_visible
  154.     unless mode_include?("R")
  155.       super
  156.     end
  157.   end
  158.  
  159.   #=============================================================================
  160.   # Object Calls
  161.   #-----------------------------------------------------------------------------
  162.   def call_cancel_handler
  163.     $game_message.choice_cancel_proc.call($game_message.choice_cancel_type - 1)
  164.     close
  165.   end
  166.  
  167.   #=============================================================================
  168.   # Conditions
  169.   #-----------------------------------------------------------------------------
  170.   def cancel_enabled?
  171.     $game_message.choice_cancel_data != nil
  172.   end
  173.  
  174.   #=============================================================================
  175.   # Reference Objects
  176.   #-----------------------------------------------------------------------------
  177.   def contents_width
  178.     if mode_include?("H")
  179.       return sp_global_width
  180.     elsif mode_include?("R")
  181.       return 3 * sp_item_width(24)
  182.     else
  183.       return sp_item_width
  184.     end
  185.   end
  186.  
  187.   def contents_height
  188.     if mode_include?("H")
  189.       return sp_item_height
  190.     elsif mode_include?("R")
  191.       return 3 * sp_item_height(24)
  192.     else
  193.       return sp_global_height
  194.     end
  195.   end
  196.  
  197.   def sp_text_size(string)
  198.     return Rect.new(0,0,0,0) if string.nil?
  199.     bitmap = Bitmap.new(1,1)
  200.     w = 8
  201.     string = string.gsub(/\\i\[\d+?\]/i) do |s|
  202.       w += 24
  203.       ""
  204.     end
  205.     string = string.gsub(/\[mode\=.+?\]/i, "")
  206.     rect = bitmap.text_size(string)
  207.     rect.width += w
  208.     bitmap.dispose
  209.     rect
  210.   end
  211.  
  212.   def sp_item_width(min = 96)
  213.     @list.each.with_index.inject(0) { |sum, (hash,i)|
  214.       [sum, (hash[:width] || [min, sp_text_size($game_message.choices[i]).width].max)].max
  215.     }
  216.   end
  217.  
  218.   def sp_item_height(min = line_height)
  219.     @list.inject(0) { |sum, hash|
  220.       [sum, (hash[:height] || [min,line_height].max)].max
  221.     } || 0
  222.   end
  223.  
  224.   def sp_global_width(min = 96)
  225.     @list.each.with_index.inject(0) { |sum, (hash,i)|
  226.       sum+(hash[:width]|| [min, sp_text_size($game_message.choices[i]).width].max)
  227.     }
  228.   end
  229.  
  230.   def sp_global_height(min = line_height)
  231.     @list.inject(0) { |sum, hash|
  232.       sum + (hash[:height] || [min,line_height].max)
  233.     } || 0
  234.   end
  235.  
  236.   def item_rect(index)
  237.     data = @list[index]||{}
  238.     rect = Rect.new
  239.     if mode_include?("R")
  240.       rect.width = sp_item_width(24)
  241.       rect.height = sp_item_height(24)
  242.       r = index.to_f / item_max
  243.       r *= 2 * Math.acos(-1)
  244.       rect.x = Math.cos(r) * sp_item_width(24) + self.contents.width / 2
  245.       rect.x -= sp_item_width(24) / 2
  246.       #rect.y = Math.sin(r) * line_height + sp_item_height(24)
  247.       rect.y = Math.sin(r) * sp_item_height(24) + self.contents.height / 2
  248.       rect.y -= sp_item_height(24) / 2
  249.     elsif mode_include?("H")
  250.       rect.width = data[:width] || 96
  251.       rect.height = contents_height
  252.       rect.x = get_special_x(index)
  253.       rect.y = 0
  254.     else
  255.       rect.width = contents_width
  256.       rect.height = data[:height] || item_height
  257.       rect.x = 0
  258.       rect.y = get_special_y(index)
  259.     end
  260.     rect
  261.   end
  262.  
  263.   def get_special_x(index)
  264.     @list[0...index].inject(0) do |sum, hash|
  265.       sum + (hash[:width] || 96)
  266.     end || 0
  267.   end
  268.  
  269.   def get_special_y(index)
  270.     @list[0...index].inject(0) do |sum, hash|
  271.       sum + (hash[:height] || line_height)
  272.     end || 0
  273.   end
  274.  
  275.   def col_max
  276.     return @list.size if mode_include?("H")
  277.     return super
  278.   end
  279.  
  280.   def row_max
  281.     return 1 if mode_include?("H")
  282.     return super
  283.   end
  284.  
  285.   def alignment
  286.     return 1 if mode_include?("R")
  287.     return 0
  288.   end
  289.  
  290.   #=============================================================================
  291.   # Drawing
  292.   #-----------------------------------------------------------------------------
  293.  
  294.   alias :zev_choice_draw_item :draw_item
  295.   def draw_item(index)
  296.     data = @list[index]
  297.     case data[:zev_ext]
  298.     when nil
  299.       zev_choice_draw_item(index)
  300.     when :image
  301.       bitmap = Cache.picture(data[:filename])
  302.       irect = item_rect(index)
  303.       brect = Rect.new(0,0,data[:width],data[:height])
  304.       contents.blt(irect.x, irect.y, bitmap, brect)
  305.     end
  306.   end
  307.  
  308. end
  309.  
  310. class Game_Message
  311.   attr_accessor :choice_data
  312.   attr_accessor :choice_cancel_data
  313.   attr_accessor :choice_cancel_proc
  314. end
  315.  
  316. class Game_Interpreter
  317.  
  318.   alias :zev_choice_clear :clear
  319.   def clear
  320.     zev_choice_clear
  321.     @choice_skip = {}
  322.   end
  323.  
  324.   def add_zev_special_choice_data(ti)
  325.     choice_data = {}
  326.     @list[ti].parameters[0].each_with_index do |c, i|
  327.       name = c.dup
  328.       if name =~ /\[switch\=(\d+?)\]/i
  329.         next unless $game_switches[$1.to_i]
  330.         name.gsub!(/\[switch\=\d+?\]/i, "")
  331.       end
  332.       choice_data[i] = name
  333.     end
  334.     s_index = $game_message.choices.size
  335.     skip    = $game_message.choice_data.size
  336.     choice_data.values.each {|s| $game_message.choices.push(s) }
  337.     $game_message.choice_data << {
  338.       :si   => s_index,
  339.       :skip => skip,
  340.       :choice_data => choice_data.keys
  341.     }
  342.     if @list[ti].parameters[1] != 0
  343.       $game_message.choice_cancel_data = {
  344.         :skip => skip,
  345.         :n    => @list[ti].parameters[1] - 1
  346.       }
  347.     end
  348.   end
  349.  
  350.   alias :zev_choice_setup_choices :setup_choices
  351.   def setup_choices(params)
  352.     $game_message.choice_data = []
  353.     $game_message.choice_cancel_data = nil
  354.     add_zev_special_choice_data(@index)
  355.     ti = @index
  356.     while @list[ti] and @list[ti].code == 102
  357.       ti += 1
  358.       ti += 1 while @list[ti].indent > @indent or [402,403,404].include? @list[ti].code
  359.       break if @list[ti].code != 102
  360.       add_zev_special_choice_data(ti)
  361.     end
  362.     $game_message.choice_proc = Proc.new {|n|
  363.       data = $game_message.choice_data.select do |h|
  364.         h[:si] <= n
  365.       end.max_by do |h|
  366.         h[:si]
  367.       end
  368.       @choice_skip[@indent] = data[:skip]
  369.       @branch[@indent] = data[:choice_data][n - data[:si]]
  370.     }
  371.     $game_message.choice_cancel_proc = Proc.new{|n|
  372.       data = $game_message.choice_cancel_data
  373.       @choice_skip[@indent] = data[:skip]
  374.       @branch[@indent] = data[:n]
  375.     }
  376.   end
  377.  
  378.   alias :zev_choice_command_102 :command_102
  379.   def command_102
  380.     return if @list[@index - 1].code == 404 if @list[@index - 1]
  381.     zev_choice_command_102
  382.   end
  383.  
  384.   def command_402
  385.     command_skip if @branch[@indent] != @params[0] or @choice_skip[@indent] != 0
  386.   end
  387.  
  388.   def command_403
  389.     command_skip if @branch[@indent] != 4 or @choice_skip[@indent] != 0
  390.   end
  391.  
  392.   def command_404
  393.     @choice_skip[@indent] -= 1 if @choice_skip[@indent]
  394.   end
  395.  
  396. end

最佳答案

查看完整内容

因为它新增了一个proc对象,但是没有像默认RGSS里面那样在使用后清除,导致存档在存储Proc对象时失败 像默认一样加个清除就好了

Lv6.析梦学徒

老鹰

梦石
40
星屑
33417
在线时间
6553 小时
注册时间
2012-5-26
帖子
3178

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

2
发表于 2021-3-4 22:41:49 | 只看该作者
因为它新增了一个proc对象,但是没有像默认RGSS里面那样在使用后清除,导致存档在存储Proc对象时失败

像默认一样加个清除就好了
  1. class Game_Message
  2.   alias :zev_message_choice_clear :clear
  3.   def clear
  4.     zev_message_choice_clear
  5.     @choice_cancel_proc = nil
  6.   end
  7. end
复制代码

评分

参与人数 1+1 收起 理由
alexncf125 + 1 谢谢大大的帮忙!~

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-28 22:25

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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