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

Project1

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

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1045
在线时间
122 小时
注册时间
2020-11-27
帖子
49
跳转到指定楼层
1
发表于 2021-1-15 18:17:00 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我使用了一个脚本,按照脚本注释后,在游戏进行时,脚本
会出现错误。
这是脚本。
RUBY 代码复制
  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.  
  36. <effect note>
  37. 第一行文字
  38. 第二行文字
  39. </effect note>
  40.     
  41. =end
  42.      ##
  43. ##----------------------------------------------------------------------------##
  44.                                                                               ##
  45. module CP             # Do not touch                                          ##
  46. module EFFECTS_WINDOW #  these lines.                                         ##
  47. ##----------------------------------------------------------------------------##
  48. ##    Config:
  49. ## The config options are below.  You can set these depending on the flavour of
  50. ## your game.  Each option is explained in a bit more detail above it.
  51. ##
  52. ##------
  53. # 窗口边框宽度
  54. EDGES = 8
  55.  
  56. # 字体大小
  57. FONT_SIZE = 16
  58.  
  59. # 是否显示文字阴影和描边
  60. SHADOW = true
  61. OUTLINE = true
  62.  
  63. # 是否显示装备的说明窗口
  64. SHOW_STATS = true
  65.  
  66. # 显示说明窗口的按键
  67. BOX_KEY = :A
  68.  
  69. # 显示类型
  70. #  0 = 按住按键才会显示
  71. #  1 = 按下按键显示或隐藏
  72. #  2 = 始终显示
  73. SHOW_TYPE = 2
  74.  
  75. # 如果上面设定为2,在这里设定是否默认显示
  76. @show = true
  77. ##----------------------------------------------------------------------------##
  78.                                                                               ##
  79.                                                                               ##
  80. ##----------------------------------------------------------------------------##
  81. ## The following lines are the actual core code of the script.  While you are
  82. ## certainly invited to look, modifying it may result in undesirable results.
  83. ## Modify at your own risk!
  84. ###----------------------------------------------------------------------------
  85.  
  86.  
  87.   def self.toggle_effects
  88.     @show = !@show if Input.trigger?(BOX_KEY)
  89.     return @show
  90.   end
  91.  
  92. end
  93. end
  94.  
  95. module SceneManager
  96.   class << self
  97.     alias :cp_rshp_run :run unless method_defined?(:cp_rshp_run)
  98.   end
  99.  
  100.   def self.run
  101.     cp_module_check_features
  102.     cp_rshp_run
  103.   end
  104.  
  105.   def self.cp_module_check_features
  106.     return if $imported["CP_FEATURES_EFFECTS"]
  107.     a1 = "One or more scripts require Neon Black's Features and Effects module."
  108.     a2 = "This can be obtained at http://cphouseset.wordpress.com/modules/"
  109.     a3 = "Please add this module and try again."
  110.     a4 = "Please contact the creator of the game to resolve this issue."
  111.     if $TEST || $BTEST
  112.       msgbox "#{a1}/n#{a2}/n#{a3}"
  113.       Thread.new{system("start http://cphouseset.wordpress.com/modules/#features")}
  114.     else
  115.       msgbox "#{a1}/n#{a4}"
  116.     end
  117.   end
  118. end
  119.  
  120. class Window_Selectable < Window_Base
  121.   def item
  122.     return nil
  123.   end
  124.  
  125.   alias :cp_itembox_update :update
  126.   def update(*args)
  127.     cp_itembox_update(*args)
  128.     show_fet_window
  129.   end
  130.  
  131.   def show_fet_window
  132.     key = key_show_features_box
  133.     show_feature_box if key && active && open?
  134.     remove_feature_box unless key && active && open?
  135.   end
  136.  
  137.   def key_show_features_box
  138.     case CP::EFFECTS_WINDOW::SHOW_TYPE
  139.     when 0
  140.       return Input.press?(CP::EFFECTS_WINDOW::BOX_KEY)
  141.     when 1
  142.       return CP::EFFECTS_WINDOW.toggle_effects
  143.     when 2
  144.       return true
  145.     else
  146.       return false
  147.     end
  148.   end
  149.  
  150.   def show_feature_box  ## Creates the box if shift is held.
  151.     if item != @last_box_item
  152.       if feature_box_item?
  153.         @feature_box.dispose unless @feature_box.nil?
  154.         rect = item_rect(@index)
  155.         x = rect.x + self.x + padding + 24 - ox
  156.         y = rect.y + line_height + self.y + padding - oy - 2
  157.         @feature_box = Window_FeaturesShow.new(item, x, y, self)
  158.         @last_box_item = item
  159.       else
  160.         remove_feature_box
  161.       end
  162.     end
  163.   end
  164.  
  165.   def feature_box_item?
  166.     item.is_a?(RPG::EquipItem) || item.is_a?(RPG::UsableItem)
  167.   end
  168.  
  169.   def remove_feature_box  ## Dispose the box.
  170.     @feature_box.dispose unless @feature_box.nil?
  171.     @feature_box = nil
  172.     @last_box_item = nil
  173.   end
  174. end
  175.  
  176. class Window_FeaturesShow < Window_Base
  177.   def initialize(item, x, y, parent)
  178.     @parent = parent
  179.     @bx = x; @by = y
  180.     @item = item
  181.     super(0, 0, 500, 500)
  182.     self.z = @parent.z + 500
  183.     self.windowskin = Cache.system("Window")
  184.     self.back_opacity = 255
  185.     self.tone = Tone.new
  186.     make_width
  187.     make_height
  188.     make_position
  189.     draw_all_items
  190.   end
  191.  
  192.   def make_width
  193.     contents.font.size = line_height
  194.     contents.font.outline = CP::EFFECTS_WINDOW::OUTLINE
  195.     contents.font.shadow = CP::EFFECTS_WINDOW::SHADOW
  196.     i = 120
  197.     unless notes.empty?
  198.       i = [i, notes.collect{|n| contents.text_size(n).width}.max + 2].max
  199.     end
  200.     unless effects.empty?
  201.       i = [i, effects.collect{|e| contents.text_size(e.vocab).width}.max + 2].max
  202.     end
  203.     unless stats.empty?
  204.       i = [i, stats.collect{|s| contents.text_size(s).width}.max + 2].max
  205.     end
  206.     self.width = i + standard_padding * 2
  207.   end
  208.  
  209.   def make_height
  210.     sw = self.width - standard_padding * 2
  211.     i = standard_padding * 2
  212.     i += notes.size * line_height
  213.     i += effects.size * line_height
  214.     i += seps * line_height / 2
  215.     unless stats.empty?
  216.       w = stats.collect{|s| contents.text_size(s).width}.max + 2
  217.       n = [sw / w, 1].max
  218.       i += (stats.size + n - 1) / n * line_height
  219.     end
  220.     self.height = i
  221.     self.visible = false if i == standard_padding * 2
  222.     create_contents
  223.     contents.font.size = line_height
  224.     contents.font.outline = false
  225.     contents.font.shadow = false
  226.     change_color(normal_color)
  227.   end
  228.  
  229.   def make_position
  230.     self.x = @bx + self.width > Graphics.width ? Graphics.width - self.width :
  231.              @bx
  232.     self.y = @by + self.height <= Graphics.height ? @by :
  233.              @by - self.height - @parent.line_height + 4 > 0 ? @by -
  234.              self.height - @parent.line_height + 4 : Graphics.height -
  235.              self.height
  236.   end
  237.  
  238.   def standard_padding
  239.     CP::EFFECTS_WINDOW::EDGES
  240.   end
  241.  
  242.   def line_height
  243.     CP::EFFECTS_WINDOW::FONT_SIZE
  244.   end
  245.  
  246.   def seps
  247.     i = -1
  248.     i += 1 unless effects.empty?
  249.     i += 1 unless notes.empty?
  250.     i += 1 unless stats.empty?
  251.     return [i, 0].max
  252.   end
  253.  
  254.   def stats
  255.     return [] unless CP::EFFECTS_WINDOW::SHOW_STATS && @item.is_a?(RPG::EquipItem)
  256.     r = []
  257.     8.times do |i|
  258.       next if @item.params[i] == 0
  259.       r.push("#{Vocab.param(i)}   #{@item.params[i]}")
  260.     end
  261.     return r
  262.   end
  263.  
  264.   def notes
  265.     @item.effect_desc
  266.   end
  267.  
  268.   def effects
  269.     if @item.is_a?(RPG::EquipItem)
  270.       @item.features
  271.     elsif @item.is_a?(RPG::UsableItem)
  272.       @item.effects
  273.     end
  274.   end
  275.  
  276.   def draw_all_items
  277.     contents.clear
  278.     y = 0
  279.     notes.each do |l|
  280.       draw_text(1, y, contents.width, line_height, l)
  281.       y += line_height
  282.     end
  283.     y += line_height / 2 unless y == 0
  284.     unless stats.empty?
  285.       w = stats.collect{|s| contents.text_size(s).width}.max + 2
  286.       xt = contents.width / w
  287.       xw = contents.width / xt
  288.       xn = 0
  289.       y -= line_height
  290.       stats.each_with_index do |s, index|
  291.         y += line_height if index % xt == 0
  292.         case s
  293.         when /(.*)   (-?)(\d+)/i
  294.           draw_text(xw * (index % xt) + 1, y, xw, line_height, "#{$1.to_s}")
  295.           draw_text(xw * (index % xt) + 1, y, xw, line_height,
  296.                     "#{$2.to_s}#{$3.to_s}  ", 2)
  297.         end
  298.       end
  299.       y += line_height
  300.     end
  301.     y += line_height / 2 unless y == 0
  302.     effects.each do |e|
  303.       draw_text(1, y, contents.width, line_height, e.vocab)
  304.       y += line_height
  305.     end
  306.   end
  307. end
  308.  
  309. class RPG::BaseItem
  310.   def effect_desc
  311.     make_effect_desc if @effect_desc.nil?
  312.     return @effect_desc
  313.   end
  314.  
  315.   def make_effect_desc
  316.     @effect_desc = []
  317.     noted = false
  318.     self.note.split(/[\r\n]+/i).each do |line|
  319.       case line
  320.       when /<effect note>/i
  321.         noted = true
  322.       when /<\/effect note>/i
  323.         break
  324.       else
  325.         @effect_desc.push("#{line}")
  326.       end
  327.     end
  328.   end
  329. end
  330.  
  331.  
  332. ###--------------------------------------------------------------------------###
  333. #  End of script.                                                              #
  334. ###--------------------------------------------------------------------------###

QQ图片20210115181426.png (17.21 KB, 下载次数: 16)

QQ图片20210115181426.png

Lv3.寻梦者

梦石
0
星屑
1045
在线时间
122 小时
注册时间
2020-11-27
帖子
49
2
 楼主| 发表于 2021-1-15 18:19:03 | 只看该作者
是游戏进行时,打开背包物品,脚本才会错误
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
24327
在线时间
5052 小时
注册时间
2016-3-8
帖子
1620
3
发表于 2021-1-15 18:42:36 | 只看该作者
本帖最后由 alexncf125 于 2021-1-15 18:45 编辑

有没有报错工程啊
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 20:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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