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

Project1

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

[已经过期] YEA得失物品脚本报错

[复制链接]

Lv1.梦旅人

梦石
0
星屑
138
在线时间
304 小时
注册时间
2014-4-11
帖子
419
跳转到指定楼层
1
发表于 2015-1-13 11:12:26 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
这个脚本我修改了显示部分 259行的地方
  1.   #--------------------------------------------------------------------------
  2.   # update_visible_counter
  3.   #--------------------------------------------------------------------------
  4.   def update_visible_counter
  5.     return if @visible_counter <= 0
  6.     @visible_counter -= 1
  7.   end
复制代码
然后得到金钱就会报错 报错的地方是window_selectable 65行
  1.   #--------------------------------------------------------------------------
  2.   # ● 计算窗口内容的高度
  3.   #--------------------------------------------------------------------------
  4.   def contents_height
  5.    [super - super % item_height, row_max * item_height].max
  6.   end
复制代码
有人能给看看是哪里错了吗
附上整个脚本

  1. $imported = {} if $imported.nil?
  2. $imported["YEA-EventWindow"] = true
  3. #==============================================================================
  4. # -----------------------------------------------------------------------------
  5. # Script Calls - These commands are used with script calls.
  6. # -----------------------------------------------------------------------------
  7. # event_window_add_text(string)
  8. # This inserts "string" text into the Event Window. Use \n to designate
  9. # linebreaks in the string. If you wish to use text codes, write them in the
  10. # strings as \\n[2] or \\c[3] to make them work properly.
  11. #
  12. # event_window_clear_text
  13. # This causes the Event Window to clear all of the stored text. You can choose
  14. # whether or not to clear the stored Event Window text every time the player
  15. # enters a new map.
  16. #==============================================================================
  17. module YEA
  18.   module EVENT_WINDOW
  19.    
  20.     HIDE_SWITCH = 98        #开关打开时窗口不显示.   
  21.     NEW_MAP_CLEAR = true    #进入新地图时是否隐藏窗口
  22.     WINDOW_WIDTH  = 200     #事件窗口宽度
  23.     VISIBLE_TIME  = 50      #窗口可见时间
  24.     MAX_LINES     = 4       # Maximum number of lines shown.
  25.     WINDOW_FADE   = 8       # Fade rate for the Event Window.
  26.     WINDOW_MOVE   = 8       # Move pixels every update
  27.     HEADER_TEXT = ""                # Text that's always used at the head.
  28.     FOUND_TEXT  = "\ec[6]获得\ec[0] "   # Text used when an item is found.
  29.     LOST_TEXT   = "\ec[4]失去\ec[0] "    # Text used when an item is lost.
  30.     AMOUNT_TEXT = "×%s"                  # Text used to display an amount.
  31.     CLOSER_TEXT = ""                   # Text that's always used at the end.

  32.   end # EVENT_WINDOW
  33. end # YEA

  34. #==============================================================================
  35. # ▼ Editting anything past this point may potentially result in causing
  36. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  37. # halitosis so edit at your own risk.
  38. #==============================================================================

  39. #==============================================================================
  40. # ■ Switch
  41. #==============================================================================

  42. module Switch
  43.   def self.hide_event_window
  44.     return false if YEA::EVENT_WINDOW::HIDE_SWITCH <= 0
  45.     return $game_switches[YEA::EVENT_WINDOW::HIDE_SWITCH]
  46.   end
  47. end # Switch

  48. #==============================================================================
  49. # ■ Numeric
  50. #==============================================================================

  51. class Numeric
  52.   
  53.   #--------------------------------------------------------------------------
  54.   # new method: group_digits
  55.   #--------------------------------------------------------------------------
  56.   unless $imported["YEA-CoreEngine"]
  57.   def group; return self.to_s; end
  58.   end # $imported["YEA-CoreEngine"]
  59.    
  60. end # Numeric

  61. #==============================================================================
  62. # ■ Game_Temp
  63. #==============================================================================

  64. class Game_Temp
  65.   
  66.   #--------------------------------------------------------------------------
  67.   # public instance variables
  68.   #--------------------------------------------------------------------------
  69.   attr_accessor :event_window_data
  70.   
  71.   #--------------------------------------------------------------------------
  72.   # new method: add_event_window_data
  73.   #--------------------------------------------------------------------------
  74.   def add_event_window_data(text)
  75.     @event_window_data = [] if @event_window_data.nil?
  76.     return if text == ""
  77.     @event_window_data.push(text)
  78.   end
  79.   
  80.   #--------------------------------------------------------------------------
  81.   # new method: clear_event_window_data
  82.   #--------------------------------------------------------------------------
  83.   def clear_event_window_data
  84.     @event_window_data = []
  85.   end
  86.   
  87. end # Game_Temp

  88. #==============================================================================
  89. # ■ Game_Interpreter
  90. #==============================================================================

  91. class Game_Interpreter
  92.   
  93.   #--------------------------------------------------------------------------
  94.   # alias method: command_125
  95.   #--------------------------------------------------------------------------
  96.   alias game_interpreter_command_125_ew command_125
  97.   def command_125
  98.     game_interpreter_command_125_ew
  99.     value = operate_value(@params[0], @params[1], @params[2])
  100.     $game_temp.clear_event_window_data
  101.     event_window_make_gold_text(value)
  102.   end
  103.   
  104.   #--------------------------------------------------------------------------
  105.   # alias method: command_126
  106.   #--------------------------------------------------------------------------
  107.   alias game_interpreter_command_126_ew command_126
  108.   def command_126
  109.     game_interpreter_command_126_ew
  110.     value = operate_value(@params[1], @params[2], @params[3])
  111.     $game_temp.clear_event_window_data
  112.     event_window_make_item_text($data_items[@params[0]], value)
  113.   end
  114.   
  115.   #--------------------------------------------------------------------------
  116.   # alias method: command_127
  117.   #--------------------------------------------------------------------------
  118.   alias game_interpreter_command_127_ew command_127
  119.   def command_127
  120.     game_interpreter_command_127_ew
  121.     value = operate_value(@params[1], @params[2], @params[3])
  122.     $game_temp.clear_event_window_data
  123.     event_window_make_item_text($data_weapons[@params[0]], value)
  124.   end
  125.   
  126.   #--------------------------------------------------------------------------
  127.   # alias method: command_128
  128.   #--------------------------------------------------------------------------
  129.   alias game_interpreter_command_128_ew command_128
  130.   def command_128
  131.     game_interpreter_command_128_ew
  132.     value = operate_value(@params[1], @params[2], @params[3])
  133.     event_window_make_item_text($data_armors[@params[0]], value)
  134.   end
  135.   
  136.   #--------------------------------------------------------------------------
  137.   # new method: event_window_make_gold_text
  138.   #--------------------------------------------------------------------------
  139.   def event_window_make_gold_text(value)
  140.     return unless SceneManager.scene_is?(Scene_Map)
  141.     return if Switch.hide_event_window
  142.     if value > 0
  143.       text = YEA::EVENT_WINDOW::FOUND_TEXT
  144.     elsif value < 0
  145.       text = YEA::EVENT_WINDOW::LOST_TEXT
  146.     else; return
  147.     end
  148.     text += sprintf("%s%s", value.abs.group, Vocab::currency_unit)
  149.     event_window_add_text(text)
  150.   end
  151.   
  152.   #--------------------------------------------------------------------------
  153.   # new method: event_window_make_item_text
  154.   #--------------------------------------------------------------------------
  155.   def event_window_make_item_text(item, value)
  156.     return unless SceneManager.scene_is?(Scene_Map)
  157.     return if Switch.hide_event_window
  158.     if value > 0
  159.       text = YEA::EVENT_WINDOW::FOUND_TEXT
  160.     elsif value < 0
  161.       text = YEA::EVENT_WINDOW::LOST_TEXT
  162.     else; return
  163.     end
  164.     text += sprintf("\ei[%d]%s", item.icon_index, item.name)
  165.     if value.abs > 1
  166.       fmt = YEA::EVENT_WINDOW::AMOUNT_TEXT
  167.       text += sprintf(fmt, value.abs.group)
  168.     end
  169.     event_window_add_text(text)
  170.   end
  171.   
  172.   #--------------------------------------------------------------------------
  173.   # new method: event_window_add_text
  174.   #--------------------------------------------------------------------------
  175.   def event_window_add_text(text)
  176.     return unless SceneManager.scene_is?(Scene_Map)
  177.     return if Switch.hide_event_window
  178.     text = YEA::EVENT_WINDOW::HEADER_TEXT + text
  179.     text += YEA::EVENT_WINDOW::CLOSER_TEXT
  180.     SceneManager.scene.event_window_add_text(text)
  181.   end
  182.   
  183.   #--------------------------------------------------------------------------
  184.   # new method: event_window_clear_text
  185.   #--------------------------------------------------------------------------
  186.   def event_window_clear_text
  187.     $game_temp.clear_event_window_data
  188.   end
  189.   
  190. end # Game_Interpreter

  191. #==============================================================================
  192. # ■ Window_EventWindow
  193. #==============================================================================

  194. class Window_EventWindow < Window_Selectable
  195.   
  196.   #--------------------------------------------------------------------------
  197.   # initialize
  198.   #--------------------------------------------------------------------------
  199.   def initialize
  200.     dw = YEA::EVENT_WINDOW::WINDOW_WIDTH
  201.     super(0, 0, dw, fitting_height(YEA::EVENT_WINDOW::MAX_LINES))
  202.     self.x -= 12
  203.     self.opacity = 0
  204.     self.contents_opacity = 0
  205.     @visible_counter = 0
  206.     modify_skin
  207.     deactivate
  208.   end
  209.   
  210.   #--------------------------------------------------------------------------
  211.   # modify_skin
  212.   #--------------------------------------------------------------------------
  213.   def modify_skin
  214.     dup_skin = self.windowskin.dup
  215.     dup_skin.clear_rect(64,  0, 64, 64)
  216.     dup_skin.clear_rect(64, 64, 32, 32)
  217.     self.windowskin = dup_skin
  218.   end
  219.   
  220.   #--------------------------------------------------------------------------
  221.   # item_max
  222.   #--------------------------------------------------------------------------
  223.   def item_max
  224.     return $game_temp.event_window_data ? $game_temp.event_window_data.size : 1
  225.   end
  226.   
  227.   #--------------------------------------------------------------------------
  228.   # update
  229.   #--------------------------------------------------------------------------
  230.   def update
  231.     super
  232.     self.visible = show_window?
  233.     update_visible_counter
  234.     update_contents_opacity
  235.     update_contents_y
  236.   end
  237.   
  238.   #--------------------------------------------------------------------------
  239.   # show_window?
  240.   #--------------------------------------------------------------------------
  241.   def show_window?
  242.     return false if $game_message.visible
  243.     return true
  244.   end
  245.   
  246.   #--------------------------------------------------------------------------
  247.   # update_visible_counter
  248.   #--------------------------------------------------------------------------
  249.   def update_visible_counter
  250.     return if @visible_counter <= 0
  251.     @visible_counter -= 1
  252.   end
  253. #~   def update_visible_counter
  254. #~     return if @visible_counter <= 0
  255. #~     return if self.contents_opacity >= 10
  256. #~     @visible_counter -= 1
  257. #~   end
  258.   #--------------------------------------------------------------------------
  259.   # update_contents_opacity
  260.   #--------------------------------------------------------------------------
  261.   def update_contents_opacity
  262.     return if @visible_counter > 0
  263.     return if self.contents_opacity <= 0
  264.     self.contents_opacity -= YEA::EVENT_WINDOW::WINDOW_FADE
  265.   end  
  266.   #--------------------------------------------------------------------------
  267.   # update_contents_y
  268.   #--------------------------------------------------------------------------
  269.   def update_contents_y
  270.     return if @visible_counter > 0
  271.     return if self.contents_opacity <= 0
  272.     self.y -= YEA::EVENT_WINDOW::WINDOW_MOVE
  273.   end
  274.   #--------------------------------------------------------------------------
  275.   # instant_hide
  276.   #--------------------------------------------------------------------------
  277.   def instant_hide
  278.     @visible_counter = 0
  279.     self.contents_opacity = 0
  280.   end
  281.   
  282.   #--------------------------------------------------------------------------
  283.   # add_text
  284.   #--------------------------------------------------------------------------
  285.   def add_text(text)
  286.     $game_temp.add_event_window_data(text)
  287.     refresh
  288.     self.contents_opacity = 255
  289.     @visible_counter = YEA::EVENT_WINDOW::VISIBLE_TIME
  290.     change_y_position
  291.     select(item_max - 1)
  292.   end
  293.   
  294.   #--------------------------------------------------------------------------
  295.   # change_y_position  这里的数字可以改变显示条的位置,数字越小越低。
  296.   #--------------------------------------------------------------------------
  297.   def change_y_position
  298.     maximum = [item_max, YEA::EVENT_WINDOW::MAX_LINES].min
  299.     self.y = Graphics.height - fitting_height(maximum) - 190
  300.   end
  301.   
  302.   #--------------------------------------------------------------------------
  303.   # refresh
  304.   #--------------------------------------------------------------------------
  305.   def refresh
  306.     create_contents
  307.     draw_all_items
  308.   end
  309.   
  310.   #--------------------------------------------------------------------------
  311.   # draw_item
  312.   #--------------------------------------------------------------------------
  313.   def draw_item(index)
  314.     $game_temp.clear_event_window_data if $game_temp.event_window_data.nil?
  315.     item = $game_temp.event_window_data[index]
  316.     return if item.nil?
  317.     rect = item_rect(index)
  318.     draw_background(rect)
  319.     rect.x += 4
  320.     rect.width -= 8
  321.     draw_text_ex(rect.x, rect.y, item)
  322.   end
  323.   
  324. #--------------------------------------------------------------------------
  325.   # draw_background
  326.   #--------------------------------------------------------------------------
  327.   def draw_background(rect)
  328.     back_color = Color.new(0, 0, 0, 130)
  329.     contents.fill_rect(rect, back_color)
  330.   end
  331.   
  332. end # Window_EventWindow

  333. #==============================================================================
  334. # ■ Scene_Map
  335. #==============================================================================

  336. class Scene_Map < Scene_Base
  337.   
  338.   #--------------------------------------------------------------------------
  339.   # alias method: create_all_windows
  340.   #--------------------------------------------------------------------------
  341.   alias scene_map_create_all_windows_event_window create_all_windows
  342.   def create_all_windows
  343.     scene_map_create_all_windows_event_window
  344.     create_event_window
  345.   end
  346.   
  347.   #--------------------------------------------------------------------------
  348.   # new method: create_event_window
  349.   #--------------------------------------------------------------------------
  350.   def create_event_window
  351.     @event_window = Window_EventWindow.new
  352.     @event_window.x = 172
  353.     @event_window.y = 30
  354.     @event_window.z = 100
  355.   end
  356.   
  357.   #--------------------------------------------------------------------------
  358.   # new method: event_window_add_text
  359.   #--------------------------------------------------------------------------
  360.   def event_window_add_text(text)
  361.     Sound.play_shop
  362.     @event_window.add_text(text)
  363.   end
  364.   
  365.   #--------------------------------------------------------------------------
  366.   # alias method: post_transfer
  367.   #--------------------------------------------------------------------------
  368.   alias scene_map_post_transfer_ew post_transfer
  369.   def post_transfer
  370.     $game_temp.clear_event_window_data if YEA::EVENT_WINDOW::NEW_MAP_CLEAR
  371.     @event_window.instant_hide
  372.     scene_map_post_transfer_ew
  373.   end
  374.   
  375. end # Scene_Map

  376. #==============================================================================
  377. #
  378. # ▼ End of File
  379. #
  380. #==============================================================================
复制代码

error.png (8.1 KB, 下载次数: 15)

error.png

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 2015-1-13 12:38:55 | 只看该作者
看看 row_max 是不是返回了 nil

点评

获取行数 可是为什么获得item的时候是好的 钱就不行了呢……所以我还是不知道在哪看……  发表于 2015-1-13 16:49
row_max 是什么 0 0 怎么看...  发表于 2015-1-13 16:39
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-15 10:51

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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