Project1
标题:
window message syntax error 求解
[打印本页]
作者:
az412519403
时间:
2013-3-21 20:16
标题:
window message syntax error 求解
window message syntax error 第七行发生错误
class Window_Message Window_Selectable
作者:
彭格列第XI代
时间:
2013-3-21 20:44
你要说明你用了什么脚本还是怎么修改了才出错了啊.....
最好附上工程或脚本
作者:
az412519403
时间:
2013-3-21 21:11
#==============================================================================
# Window_Message
#------------------------------------------------------------------------------
# 本窗口用来显示文本讯息。
#==============================================================================
class Window_Message Window_Selectable
#--------------------------------------------------------------------------
# 常数
#--------------------------------------------------------------------------
MAX_LINE = 4 # 行数上限
#--------------------------------------------------------------------------
# 对象初始化
#--------------------------------------------------------------------------
def initialize
super(0, 288, 544, 128)
self.z = 200
self.active = false
self.index = -1
self.openness = 0
@opening = false # 窗口展开的标帜
@closing = false # 窗口合拢的标帜
@text = nil # 剩余的要显示的文本
@contents_x = 0 # 要绘制的下一个字符的X坐标
@contents_y = 0 # 要绘制的下一个字符的Y坐标
@line_count = 0 # 到目前为止已经绘制的行数总计
@wait_count = 0 # 等待次数总计
@background = 0 # 窗口风格类型(0-普通,1-图片,2-透明背景)
@position = 2 # 窗口显示位置
@show_fast = false # 快速前进标帜
@line_show_fast = false # 按行快速前进标帜
@pause_skip = false # 输入待命省略标帜
create_gold_window
create_number_input_window
create_back_sprite
end
#--------------------------------------------------------------------------
# 清除窗口
#--------------------------------------------------------------------------
def dispose
super
dispose_gold_window
dispose_number_input_window
dispose_back_sprite
end
#--------------------------------------------------------------------------
# 帧更新
#--------------------------------------------------------------------------
def update
super
update_gold_window
update_number_input_window
update_back_sprite
update_show_fast
unless @opening or @closing # 窗口不是处于正在展开或合拢的状态
if @wait_count 0 # 等待于文本范围内
@wait_count -= 1
elsif self.pause # 等待文本量增加
input_pause
elsif self.active # 输入选择资讯
input_choice
elsif @number_input_window.visible # 输入数字资讯
input_number
elsif @text != nil # 存在更多的文本
update_message # 更新讯息
elsif continue # 文本持续显示中
start_message # 讯息显示开始
open # 展开窗口
$game_message.visible = true
else # 不再继续显示文本
close # 合拢窗口
$game_message.visible = @closing
end
end
end
#--------------------------------------------------------------------------
# 创建所携资金资讯窗口
#--------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_Gold.new(384, 0)
@gold_window.openness = 0
end
#--------------------------------------------------------------------------
# 创建数字输入窗口
#--------------------------------------------------------------------------
def create_number_input_window
@number_input_window = Window_NumberInput.new
@number_input_window.visible = false
end
#--------------------------------------------------------------------------
# 绘制窗口底部皮肤图片(精灵物设)
#--------------------------------------------------------------------------
def create_back_sprite
@back_sprite = Sprite.new
@back_sprite.bitmap = Cache.system(MessageBack)
@back_sprite.visible = (@background == 1)
@back_sprite.z = 190
end
#--------------------------------------------------------------------------
# 清除所携资金资讯窗口
#--------------------------------------------------------------------------
def dispose_gold_window
@gold_window.dispose
end
#--------------------------------------------------------------------------
# 清除数字输入窗口
#--------------------------------------------------------------------------
def dispose_number_input_window
@number_input_window.dispose
end
#--------------------------------------------------------------------------
# 清除窗口底部皮肤图片
#--------------------------------------------------------------------------
def dispose_back_sprite
@back_sprite.dispose
end
#--------------------------------------------------------------------------
# 更新所携资金资讯窗口所显示的资讯
#--------------------------------------------------------------------------
def update_gold_window
@gold_window.update
end
#--------------------------------------------------------------------------
# 更新数字输入窗口所显示的资讯
#--------------------------------------------------------------------------
def update_number_input_window
@number_input_window.update
end
#--------------------------------------------------------------------------
# 重新绘制窗口底部皮肤图片
#--------------------------------------------------------------------------
def update_back_sprite
@back_sprite.visible = (@background == 1)
@back_sprite.y = y - 16
@back_sprite.opacity = openness
@back_sprite.update
end
#--------------------------------------------------------------------------
# 更新快速前进标帜
#--------------------------------------------------------------------------
def update_show_fast
if self.pause or self.openness 255
@show_fast = false
elsif Input.trigger(InputC) and @wait_count 2
@show_fast = true
elsif not Input.press(InputC)
@show_fast = false
end
if @show_fast and @wait_count 0
@wait_count -= 1
end
end
#--------------------------------------------------------------------------
# 判定是否应该持续显示下一条讯息
#--------------------------------------------------------------------------
def continue
return true if $game_message.num_input_variable_id 0
return false if $game_message.texts.empty
if self.openness 0 and not $game_temp.in_battle
return false if @background != $game_message.background
return false if @position != $game_message.position
end
return true
end
#--------------------------------------------------------------------------
# 讯息显示开始
#--------------------------------------------------------------------------
def start_message
@text =
for i in 0...$game_message.texts.size
@text += · if i = $game_message.choice_start
@text += $game_message.texts[i].clone + x00
end
@item_max = $game_message.choice_max
convert_special_characters
reset_window
new_page
end
#--------------------------------------------------------------------------
# 绘制新讯息页
#--------------------------------------------------------------------------
def new_page
contents.clear
if $game_message.face_name.empty
@contents_x = 0
else
name = $game_message.face_name
index = $game_message.face_index
draw_face(name, index, 0, 0)
@contents_x = 112
end
@contents_y = 0
@line_count = 0
@show_fast = false
@line_show_fast = false
@pause_skip = false
contents.font.color = text_color(0)
end
#--------------------------------------------------------------------------
# 绘制新行
#--------------------------------------------------------------------------
def new_line
if $game_message.face_name.empty
@contents_x = 0
else
@contents_x = 112
end
@contents_y += WLH
@line_count += 1
@line_show_fast = false
end
#--------------------------------------------------------------------------
# 转换特殊控制符
#--------------------------------------------------------------------------
def convert_special_characters
@text.gsub!(V[([0-9]+)]i) { $game_variables[$1.to_i] }
@text.gsub!(V[([0-9]+)]i) { $game_variables[$1.to_i] }
@text.gsub!(N[([0-9]+)]i) { $game_actors[$1.to_i].name }
@text.gsub!(C[([0-9]+)]i) { x01[#{$1}] }
@text.gsub!(G) { x02 }
@text.gsub!(.) { x03 }
@text.gsub!() { x04 }
@text.gsub!(!) { x05 }
@text.gsub!() { x06 }
@text.gsub!() { x07 }
@text.gsub!(^) { x08 }
@text.gsub!() { }
end
#--------------------------------------------------------------------------
# 设置窗口显示类型及窗口位置
#--------------------------------------------------------------------------
def reset_window
@background = $game_message.background
@position = $game_message.position
if @background == 0 # 普通窗口
self.opacity = 255
else # 图片窗口和透明窗口的情况下
self.opacity = 0
end
case @position
when 0 # 荧幕上部
self.y = 0
@gold_window.y = 360
when 1 # 荧幕中心
self.y = 144
@gold_window.y = 0
when 2 # 荧幕底部
self.y = 288
@gold_window.y = 0
end
end
#--------------------------------------------------------------------------
# 讯息显示结束
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
@gold_window.close
@number_input_window.active = false
@number_input_window.visible = false
$game_message.main_proc.call if $game_message.main_proc != nil
$game_message.clear
end
#--------------------------------------------------------------------------
# 更新文本讯息内容显示
#--------------------------------------------------------------------------
def update_message
loop do
c = @text.slice!(.m) # 获取下一个字符资讯
case c
when nil # 没有要绘制的文本了
finish_message # 结束更新
break
when x00 # 换至新行
new_line
if @line_count = MAX_LINE # 当前页的文本行数已经达到上限
unless @text.empty # 在没有有更多内容的情况下
self.pause = true # 文本暂停显示,等待按键输入
break
end
end
when x01 # C[n] (更改字符颜色)
@text.sub!([([0-9]+)], )
contents.font.color = text_color($1.to_i)
next
when x02 # G (显示所携资金)
@gold_window.refresh
@gold_window.open
when x03 # . (等待0.25秒)
@wait_count = 15
break
when x04 # (等待1秒)
@wait_count = 60
break
when x05 # ! (文本暂停显示,等待按键输入)
self.pause = true
break
when x06 # (启用文本快速显示功能)
@line_show_fast = true
when x07 # (禁用文本快速显示功能)
@line_show_fast = false
when x08 # ^ (不等待按键输入)
@pause_skip = true
else # 普通字符
contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
c_width = contents.text_size(c).width
@contents_x += c_width
end
break unless @show_fast or @line_show_fast
end
end
#--------------------------------------------------------------------------
# 停止更新文本讯息内容显示
#--------------------------------------------------------------------------
def finish_message
if $game_message.choice_max 0
start_choice
elsif $game_message.num_input_variable_id 0
start_number_input
elsif @pause_skip
terminate_message
else
self.pause = true
end
@wait_count = 10
@text = nil
end
#--------------------------------------------------------------------------
# 开始准备接收选项输入资讯
#--------------------------------------------------------------------------
def start_choice
self.active = true
self.index = 0
end
#--------------------------------------------------------------------------
# 开始准备接收数字输入资讯
#--------------------------------------------------------------------------
def start_number_input
digits_max = $game_message.num_input_digits_max
number = $game_variables[$game_message.num_input_variable_id]
@number_input_window.digits_max = digits_max
@number_input_window.number = number
if $game_message.face_name.empty
@number_input_window.x = x
else
@number_input_window.x = x + 112
end
@number_input_window.y = y + @contents_y
@number_input_window.active = true
@number_input_window.visible = true
@number_input_window.update
end
#--------------------------------------------------------------------------
# 更新光标绘制
#--------------------------------------------------------------------------
def update_cursor
if @index = 0
x = $game_message.face_name.empty 0 112
y = ($game_message.choice_start + @index) WLH
self.cursor_rect.set(x, y, contents.width - x, WLH)
else
self.cursor_rect.empty
end
end
#--------------------------------------------------------------------------
# 持续显示的文本资讯的输入处理
#--------------------------------------------------------------------------
def input_pause
if Input.trigger(InputB) or Input.trigger(InputC)
self.pause = false
if @text != nil and not @text.empty
new_page if @line_count = MAX_LINE
else
terminate_message
end
end
end
#--------------------------------------------------------------------------
# 接收选项输入资讯
#--------------------------------------------------------------------------
def input_choice
if Input.trigger(InputB)
if $game_message.choice_cancel_type 0
Sound.play_cancel
$game_message.choice_proc.call($game_message.choice_cancel_type - 1)
terminate_message
end
elsif Input.trigger(InputC)
Sound.play_decision
$game_message.choice_proc.call(self.index)
terminate_message
end
end
#--------------------------------------------------------------------------
# 数字输入处理
#--------------------------------------------------------------------------
def input_number
if Input.trigger(InputC)
Sound.play_decision
$game_variables[$game_message.num_input_variable_id] =
@number_input_window.number
$game_map.need_refresh = true
terminate_message
end
end
end
作者:
Password
时间:
2013-3-21 21:13
很显然……第7行少了个"<"号
class Window_Message < Window_Selectable
复制代码
作者:
az412519403
时间:
2013-3-21 21:25
谢啦 自己乱改动结果就改错了
作者:
az412519403
时间:
2013-3-21 21:26
接下来56行又错了
作者:
az412519403
时间:
2013-3-21 21:27
if @wait_count 0 # 等待于文本范围内
复制代码
作者:
芯☆淡茹水
时间:
2013-3-21 21:56
本帖最后由 芯☆淡茹水 于 2013-3-21 21:57 编辑
if @wait_count == 0
复制代码
作者:
az412519403
时间:
2013-3-22 18:24
如此的话········我希望哪位大神把他的脚本复制一份·········· 没准以后还有错的
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1