Project1
标题:
YEA得失物品脚本报错
[打印本页]
作者:
fox1313304
时间:
2015-1-13 11:12
标题:
YEA得失物品脚本报错
这个脚本我修改了显示部分 259行的地方
#--------------------------------------------------------------------------
# update_visible_counter
#--------------------------------------------------------------------------
def update_visible_counter
return if @visible_counter <= 0
@visible_counter -= 1
end
复制代码
然后得到金钱就会报错 报错的地方是window_selectable 65行
#--------------------------------------------------------------------------
# ● 计算窗口内容的高度
#--------------------------------------------------------------------------
def contents_height
[super - super % item_height, row_max * item_height].max
end
复制代码
有人能给看看是哪里错了吗
附上整个脚本
$imported = {} if $imported.nil?
$imported["YEA-EventWindow"] = true
#==============================================================================
# -----------------------------------------------------------------------------
# Script Calls - These commands are used with script calls.
# -----------------------------------------------------------------------------
# event_window_add_text(string)
# This inserts "string" text into the Event Window. Use \n to designate
# linebreaks in the string. If you wish to use text codes, write them in the
# strings as \\n[2] or \\c[3] to make them work properly.
#
# event_window_clear_text
# This causes the Event Window to clear all of the stored text. You can choose
# whether or not to clear the stored Event Window text every time the player
# enters a new map.
#==============================================================================
module YEA
module EVENT_WINDOW
HIDE_SWITCH = 98 #开关打开时窗口不显示.
NEW_MAP_CLEAR = true #进入新地图时是否隐藏窗口
WINDOW_WIDTH = 200 #事件窗口宽度
VISIBLE_TIME = 50 #窗口可见时间
MAX_LINES = 4 # Maximum number of lines shown.
WINDOW_FADE = 8 # Fade rate for the Event Window.
WINDOW_MOVE = 8 # Move pixels every update
HEADER_TEXT = "" # Text that's always used at the head.
FOUND_TEXT = "\ec[6]获得\ec[0] " # Text used when an item is found.
LOST_TEXT = "\ec[4]失去\ec[0] " # Text used when an item is lost.
AMOUNT_TEXT = "×%s" # Text used to display an amount.
CLOSER_TEXT = "" # Text that's always used at the end.
end # EVENT_WINDOW
end # YEA
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================
#==============================================================================
# ■ Switch
#==============================================================================
module Switch
def self.hide_event_window
return false if YEA::EVENT_WINDOW::HIDE_SWITCH <= 0
return $game_switches[YEA::EVENT_WINDOW::HIDE_SWITCH]
end
end # Switch
#==============================================================================
# ■ Numeric
#==============================================================================
class Numeric
#--------------------------------------------------------------------------
# new method: group_digits
#--------------------------------------------------------------------------
unless $imported["YEA-CoreEngine"]
def group; return self.to_s; end
end # $imported["YEA-CoreEngine"]
end # Numeric
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :event_window_data
#--------------------------------------------------------------------------
# new method: add_event_window_data
#--------------------------------------------------------------------------
def add_event_window_data(text)
@event_window_data = [] if @event_window_data.nil?
return if text == ""
@event_window_data.push(text)
end
#--------------------------------------------------------------------------
# new method: clear_event_window_data
#--------------------------------------------------------------------------
def clear_event_window_data
@event_window_data = []
end
end # Game_Temp
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# alias method: command_125
#--------------------------------------------------------------------------
alias game_interpreter_command_125_ew command_125
def command_125
game_interpreter_command_125_ew
value = operate_value(@params[0], @params[1], @params[2])
$game_temp.clear_event_window_data
event_window_make_gold_text(value)
end
#--------------------------------------------------------------------------
# alias method: command_126
#--------------------------------------------------------------------------
alias game_interpreter_command_126_ew command_126
def command_126
game_interpreter_command_126_ew
value = operate_value(@params[1], @params[2], @params[3])
$game_temp.clear_event_window_data
event_window_make_item_text($data_items[@params[0]], value)
end
#--------------------------------------------------------------------------
# alias method: command_127
#--------------------------------------------------------------------------
alias game_interpreter_command_127_ew command_127
def command_127
game_interpreter_command_127_ew
value = operate_value(@params[1], @params[2], @params[3])
$game_temp.clear_event_window_data
event_window_make_item_text($data_weapons[@params[0]], value)
end
#--------------------------------------------------------------------------
# alias method: command_128
#--------------------------------------------------------------------------
alias game_interpreter_command_128_ew command_128
def command_128
game_interpreter_command_128_ew
value = operate_value(@params[1], @params[2], @params[3])
event_window_make_item_text($data_armors[@params[0]], value)
end
#--------------------------------------------------------------------------
# new method: event_window_make_gold_text
#--------------------------------------------------------------------------
def event_window_make_gold_text(value)
return unless SceneManager.scene_is?(Scene_Map)
return if Switch.hide_event_window
if value > 0
text = YEA::EVENT_WINDOW::FOUND_TEXT
elsif value < 0
text = YEA::EVENT_WINDOW::LOST_TEXT
else; return
end
text += sprintf("%s%s", value.abs.group, Vocab::currency_unit)
event_window_add_text(text)
end
#--------------------------------------------------------------------------
# new method: event_window_make_item_text
#--------------------------------------------------------------------------
def event_window_make_item_text(item, value)
return unless SceneManager.scene_is?(Scene_Map)
return if Switch.hide_event_window
if value > 0
text = YEA::EVENT_WINDOW::FOUND_TEXT
elsif value < 0
text = YEA::EVENT_WINDOW::LOST_TEXT
else; return
end
text += sprintf("\ei[%d]%s", item.icon_index, item.name)
if value.abs > 1
fmt = YEA::EVENT_WINDOW::AMOUNT_TEXT
text += sprintf(fmt, value.abs.group)
end
event_window_add_text(text)
end
#--------------------------------------------------------------------------
# new method: event_window_add_text
#--------------------------------------------------------------------------
def event_window_add_text(text)
return unless SceneManager.scene_is?(Scene_Map)
return if Switch.hide_event_window
text = YEA::EVENT_WINDOW::HEADER_TEXT + text
text += YEA::EVENT_WINDOW::CLOSER_TEXT
SceneManager.scene.event_window_add_text(text)
end
#--------------------------------------------------------------------------
# new method: event_window_clear_text
#--------------------------------------------------------------------------
def event_window_clear_text
$game_temp.clear_event_window_data
end
end # Game_Interpreter
#==============================================================================
# ■ Window_EventWindow
#==============================================================================
class Window_EventWindow < Window_Selectable
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize
dw = YEA::EVENT_WINDOW::WINDOW_WIDTH
super(0, 0, dw, fitting_height(YEA::EVENT_WINDOW::MAX_LINES))
self.x -= 12
self.opacity = 0
self.contents_opacity = 0
@visible_counter = 0
modify_skin
deactivate
end
#--------------------------------------------------------------------------
# modify_skin
#--------------------------------------------------------------------------
def modify_skin
dup_skin = self.windowskin.dup
dup_skin.clear_rect(64, 0, 64, 64)
dup_skin.clear_rect(64, 64, 32, 32)
self.windowskin = dup_skin
end
#--------------------------------------------------------------------------
# item_max
#--------------------------------------------------------------------------
def item_max
return $game_temp.event_window_data ? $game_temp.event_window_data.size : 1
end
#--------------------------------------------------------------------------
# update
#--------------------------------------------------------------------------
def update
super
self.visible = show_window?
update_visible_counter
update_contents_opacity
update_contents_y
end
#--------------------------------------------------------------------------
# show_window?
#--------------------------------------------------------------------------
def show_window?
return false if $game_message.visible
return true
end
#--------------------------------------------------------------------------
# update_visible_counter
#--------------------------------------------------------------------------
def update_visible_counter
return if @visible_counter <= 0
@visible_counter -= 1
end
#~ def update_visible_counter
#~ return if @visible_counter <= 0
#~ return if self.contents_opacity >= 10
#~ @visible_counter -= 1
#~ end
#--------------------------------------------------------------------------
# update_contents_opacity
#--------------------------------------------------------------------------
def update_contents_opacity
return if @visible_counter > 0
return if self.contents_opacity <= 0
self.contents_opacity -= YEA::EVENT_WINDOW::WINDOW_FADE
end
#--------------------------------------------------------------------------
# update_contents_y
#--------------------------------------------------------------------------
def update_contents_y
return if @visible_counter > 0
return if self.contents_opacity <= 0
self.y -= YEA::EVENT_WINDOW::WINDOW_MOVE
end
#--------------------------------------------------------------------------
# instant_hide
#--------------------------------------------------------------------------
def instant_hide
@visible_counter = 0
self.contents_opacity = 0
end
#--------------------------------------------------------------------------
# add_text
#--------------------------------------------------------------------------
def add_text(text)
$game_temp.add_event_window_data(text)
refresh
self.contents_opacity = 255
@visible_counter = YEA::EVENT_WINDOW::VISIBLE_TIME
change_y_position
select(item_max - 1)
end
#--------------------------------------------------------------------------
# change_y_position 这里的数字可以改变显示条的位置,数字越小越低。
#--------------------------------------------------------------------------
def change_y_position
maximum = [item_max, YEA::EVENT_WINDOW::MAX_LINES].min
self.y = Graphics.height - fitting_height(maximum) - 190
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
create_contents
draw_all_items
end
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
$game_temp.clear_event_window_data if $game_temp.event_window_data.nil?
item = $game_temp.event_window_data[index]
return if item.nil?
rect = item_rect(index)
draw_background(rect)
rect.x += 4
rect.width -= 8
draw_text_ex(rect.x, rect.y, item)
end
#--------------------------------------------------------------------------
# draw_background
#--------------------------------------------------------------------------
def draw_background(rect)
back_color = Color.new(0, 0, 0, 130)
contents.fill_rect(rect, back_color)
end
end # Window_EventWindow
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# alias method: create_all_windows
#--------------------------------------------------------------------------
alias scene_map_create_all_windows_event_window create_all_windows
def create_all_windows
scene_map_create_all_windows_event_window
create_event_window
end
#--------------------------------------------------------------------------
# new method: create_event_window
#--------------------------------------------------------------------------
def create_event_window
@event_window = Window_EventWindow.new
@event_window.x = 172
@event_window.y = 30
@event_window.z = 100
end
#--------------------------------------------------------------------------
# new method: event_window_add_text
#--------------------------------------------------------------------------
def event_window_add_text(text)
Sound.play_shop
@event_window.add_text(text)
end
#--------------------------------------------------------------------------
# alias method: post_transfer
#--------------------------------------------------------------------------
alias scene_map_post_transfer_ew post_transfer
def post_transfer
$game_temp.clear_event_window_data if YEA::EVENT_WINDOW::NEW_MAP_CLEAR
@event_window.instant_hide
scene_map_post_transfer_ew
end
end # Scene_Map
#==============================================================================
#
# ▼ End of File
#
#==============================================================================
复制代码
error.png
(8.1 KB, 下载次数: 15)
下载附件
保存到相册
2015-1-13 11:10 上传
作者:
taroxd
时间:
2015-1-13 12:38
看看 row_max 是不是返回了 nil
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1