查看: 2383|回复: 2

[已经过期] 使用脚本后出现错误

[复制链接]
梦石
0
星屑
1107
在线时间
126 小时
注册时间
2020-11-27
回帖
48
发表于 2021-1-15 18:17:00 | 显示全部楼层 |阅读模式

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

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

×
我使用了一个脚本,按照脚本注释后,在游戏进行时,脚本
会出现错误。
这是脚本。
  1. ##----------------------------------------------------------------------------##
  2. ## 物品说明窗口 v1.0
  3. ## Created by Neon Black
  4. ##
  5. ## For both commercial and non-commercial use as long as credit is given to
  6. ## Neon Black and any additional authors.  Licensed under Creative Commons
  7. ## CC BY 3.0 - http://creativecommons.org/licenses/by/3.0/.
  8. ##----------------------------------------------------------------------------##
  9.                                                                               ##
  10. ##----------------------------------------------------------------------------##
  11. ##    Revision Info:
  12. ## v1.0 - 3.3.2013
  13. ##  Wrote and debugged main script
  14. ##----------------------------------------------------------------------------##
  15.                                                                               ##
  16. $imported ||= {}                                                              ##
  17. $imported["EFFECTS_BOX"] = 1.0                                                ##
  18.                                                                               ##
  19. ##----------------------------------------------------------------------------##
  20. ##    Instructions:
  21. ## 前置脚本: Neon Black - 特性和效果模块.  You can
  22. ## obtain it from http://cphouseset.wordpress.com/modules/.  If you do not
  23. ## import it, you will get errors.
  24. ##
  25. ## This script is plug and play.  It allows a pop-up boxes to display on equips,
  26. ## items, and skills.  You can choose to have these pop-ups be constant, toggle
  27. ## with a button press, or only appear while a key is held down.  These display
  28. ## 3 bits of information.  First an added note, second all the stats equipping
  29. ## the item will provide, and finally all the effects or features of the item.
  30. ## A note can be added using <effect note> and </effect note> and placing your
  31. ## note in between those tags, like so:
  32. ##
  33. =begin
  34. 使用物品/武器/护甲备注:

  35. <effect note>
  36. 第一行文字
  37. 第二行文字
  38. </effect note>
  39.      
  40. =end
  41.      ##
  42. ##----------------------------------------------------------------------------##
  43.                                                                               ##
  44. module CP             # Do not touch                                          ##
  45. module EFFECTS_WINDOW #  these lines.                                         ##
  46. ##----------------------------------------------------------------------------##
  47. ##    Config:
  48. ## The config options are below.  You can set these depending on the flavour of
  49. ## your game.  Each option is explained in a bit more detail above it.
  50. ##
  51. ##------
  52. # 窗口边框宽度
  53. EDGES = 8

  54. # 字体大小
  55. FONT_SIZE = 16

  56. # 是否显示文字阴影和描边
  57. SHADOW = true
  58. OUTLINE = true

  59. # 是否显示装备的说明窗口
  60. SHOW_STATS = true

  61. # 显示说明窗口的按键
  62. BOX_KEY = :A

  63. # 显示类型
  64. #  0 = 按住按键才会显示
  65. #  1 = 按下按键显示或隐藏
  66. #  2 = 始终显示
  67. SHOW_TYPE = 2

  68. # 如果上面设定为2,在这里设定是否默认显示
  69. @show = true
  70. ##----------------------------------------------------------------------------##
  71.                                                                               ##
  72.                                                                               ##
  73. ##----------------------------------------------------------------------------##
  74. ## The following lines are the actual core code of the script.  While you are
  75. ## certainly invited to look, modifying it may result in undesirable results.
  76. ## Modify at your own risk!
  77. ###----------------------------------------------------------------------------


  78.   def self.toggle_effects
  79.     @show = !@show if Input.trigger?(BOX_KEY)
  80.     return @show
  81.   end

  82. end
  83. end

  84. module SceneManager
  85.   class << self
  86.     alias :cp_rshp_run :run unless method_defined?(:cp_rshp_run)
  87.   end

  88.   def self.run
  89.     cp_module_check_features
  90.     cp_rshp_run
  91.   end

  92.   def self.cp_module_check_features
  93.     return if $imported["CP_FEATURES_EFFECTS"]
  94.     a1 = "One or more scripts require Neon Black's Features and Effects module."
  95.     a2 = "This can be obtained at http://cphouseset.wordpress.com/modules/"
  96.     a3 = "Please add this module and try again."
  97.     a4 = "Please contact the creator of the game to resolve this issue."
  98.     if $TEST || $BTEST
  99.       msgbox "#{a1}/n#{a2}/n#{a3}"
  100.       Thread.new{system("start http://cphouseset.wordpress.com/modules/#features")}
  101.     else
  102.       msgbox "#{a1}/n#{a4}"
  103.     end
  104.   end
  105. end

  106. class Window_Selectable < Window_Base
  107.   def item
  108.     return nil
  109.   end

  110.   alias :cp_itembox_update :update
  111.   def update(*args)
  112.     cp_itembox_update(*args)
  113.     show_fet_window
  114.   end

  115.   def show_fet_window
  116.     key = key_show_features_box
  117.     show_feature_box if key && active && open?
  118.     remove_feature_box unless key && active && open?
  119.   end

  120.   def key_show_features_box
  121.     case CP::EFFECTS_WINDOW::SHOW_TYPE
  122.     when 0
  123.       return Input.press?(CP::EFFECTS_WINDOW::BOX_KEY)
  124.     when 1
  125.       return CP::EFFECTS_WINDOW.toggle_effects
  126.     when 2
  127.       return true
  128.     else
  129.       return false
  130.     end
  131.   end

  132.   def show_feature_box  ## Creates the box if shift is held.
  133.     if item != @last_box_item
  134.       if feature_box_item?
  135.         @feature_box.dispose unless @feature_box.nil?
  136.         rect = item_rect(@index)
  137.         x = rect.x + self.x + padding + 24 - ox
  138.         y = rect.y + line_height + self.y + padding - oy - 2
  139.         @feature_box = Window_FeaturesShow.new(item, x, y, self)
  140.         @last_box_item = item
  141.       else
  142.         remove_feature_box
  143.       end
  144.     end
  145.   end

  146.   def feature_box_item?
  147.     item.is_a?(RPG::EquipItem) || item.is_a?(RPG::UsableItem)
  148.   end

  149.   def remove_feature_box  ## Dispose the box.
  150.     @feature_box.dispose unless @feature_box.nil?
  151.     @feature_box = nil
  152.     @last_box_item = nil
  153.   end
  154. end

  155. class Window_FeaturesShow < Window_Base
  156.   def initialize(item, x, y, parent)
  157.     @parent = parent
  158.     @bx = x; @by = y
  159.     @item = item
  160.     super(0, 0, 500, 500)
  161.     self.z = @parent.z + 500
  162.     self.windowskin = Cache.system("Window")
  163.     self.back_opacity = 255
  164.     self.tone = Tone.new
  165.     make_width
  166.     make_height
  167.     make_position
  168.     draw_all_items
  169.   end

  170.   def make_width
  171.     contents.font.size = line_height
  172.     contents.font.outline = CP::EFFECTS_WINDOW::OUTLINE
  173.     contents.font.shadow = CP::EFFECTS_WINDOW::SHADOW
  174.     i = 120
  175.     unless notes.empty?
  176.       i = [i, notes.collect{|n| contents.text_size(n).width}.max + 2].max
  177.     end
  178.     unless effects.empty?
  179.       i = [i, effects.collect{|e| contents.text_size(e.vocab).width}.max + 2].max
  180.     end
  181.     unless stats.empty?
  182.       i = [i, stats.collect{|s| contents.text_size(s).width}.max + 2].max
  183.     end
  184.     self.width = i + standard_padding * 2
  185.   end

  186.   def make_height
  187.     sw = self.width - standard_padding * 2
  188.     i = standard_padding * 2
  189.     i += notes.size * line_height
  190.     i += effects.size * line_height
  191.     i += seps * line_height / 2
  192.     unless stats.empty?
  193.       w = stats.collect{|s| contents.text_size(s).width}.max + 2
  194.       n = [sw / w, 1].max
  195.       i += (stats.size + n - 1) / n * line_height
  196.     end
  197.     self.height = i
  198.     self.visible = false if i == standard_padding * 2
  199.     create_contents
  200.     contents.font.size = line_height
  201.     contents.font.outline = false
  202.     contents.font.shadow = false
  203.     change_color(normal_color)
  204.   end

  205.   def make_position
  206.     self.x = @bx + self.width > Graphics.width ? Graphics.width - self.width :
  207.              @bx
  208.     self.y = @by + self.height <= Graphics.height ? @by :
  209.              @by - self.height - @parent.line_height + 4 > 0 ? @by -
  210.              self.height - @parent.line_height + 4 : Graphics.height -
  211.              self.height
  212.   end

  213.   def standard_padding
  214.     CP::EFFECTS_WINDOW::EDGES
  215.   end

  216.   def line_height
  217.     CP::EFFECTS_WINDOW::FONT_SIZE
  218.   end

  219.   def seps
  220.     i = -1
  221.     i += 1 unless effects.empty?
  222.     i += 1 unless notes.empty?
  223.     i += 1 unless stats.empty?
  224.     return [i, 0].max
  225.   end

  226.   def stats
  227.     return [] unless CP::EFFECTS_WINDOW::SHOW_STATS && @item.is_a?(RPG::EquipItem)
  228.     r = []
  229.     8.times do |i|
  230.       next if @item.params[i] == 0
  231.       r.push("#{Vocab.param(i)}   #{@item.params[i]}")
  232.     end
  233.     return r
  234.   end

  235.   def notes
  236.     @item.effect_desc
  237.   end

  238.   def effects
  239.     if @item.is_a?(RPG::EquipItem)
  240.       @item.features
  241.     elsif @item.is_a?(RPG::UsableItem)
  242.       @item.effects
  243.     end
  244.   end

  245.   def draw_all_items
  246.     contents.clear
  247.     y = 0
  248.     notes.each do |l|
  249.       draw_text(1, y, contents.width, line_height, l)
  250.       y += line_height
  251.     end
  252.     y += line_height / 2 unless y == 0
  253.     unless stats.empty?
  254.       w = stats.collect{|s| contents.text_size(s).width}.max + 2
  255.       xt = contents.width / w
  256.       xw = contents.width / xt
  257.       xn = 0
  258.       y -= line_height
  259.       stats.each_with_index do |s, index|
  260.         y += line_height if index % xt == 0
  261.         case s
  262.         when /(.*)   (-?)(\d+)/i
  263.           draw_text(xw * (index % xt) + 1, y, xw, line_height, "#{$1.to_s}")
  264.           draw_text(xw * (index % xt) + 1, y, xw, line_height,
  265.                     "#{$2.to_s}#{$3.to_s}  ", 2)
  266.         end
  267.       end
  268.       y += line_height
  269.     end
  270.     y += line_height / 2 unless y == 0
  271.     effects.each do |e|
  272.       draw_text(1, y, contents.width, line_height, e.vocab)
  273.       y += line_height
  274.     end
  275.   end
  276. end

  277. class RPG::BaseItem
  278.   def effect_desc
  279.     make_effect_desc if @effect_desc.nil?
  280.     return @effect_desc
  281.   end

  282.   def make_effect_desc
  283.     @effect_desc = []
  284.     noted = false
  285.     self.note.split(/[\r\n]+/i).each do |line|
  286.       case line
  287.       when /<effect note>/i
  288.         noted = true
  289.       when /<\/effect note>/i
  290.         break
  291.       else
  292.         @effect_desc.push("#{line}")
  293.       end
  294.     end
  295.   end
  296. end


  297. ###--------------------------------------------------------------------------###
  298. #  End of script.                                                              #
  299. ###--------------------------------------------------------------------------###
复制代码
QQ图片20210115181426.png
梦石
0
星屑
1107
在线时间
126 小时
注册时间
2020-11-27
回帖
48
 楼主| 发表于 2021-1-15 18:19:03 | 显示全部楼层
是游戏进行时,打开背包物品,脚本才会错误
回复

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2021-1-15 18:42:36 | 显示全部楼层
本帖最后由 alexncf125 于 2021-1-15 18:45 编辑

有没有报错工程啊
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部