本帖最后由 寒凌天 于 2020-1-2 15:54 编辑
def command_355 # script 设置第一行 script = @list[@index].parameters[0] + "\n" # 循环 loop do # 下一个事件指令在脚本 2 行以上的情况下 if @list[@index+1].code == 655 # 添加到 script 2 行以后 script += @list[@index+1].parameters[0] + "\n" # 事件指令不在脚本 2 行以上的情况下 else # 中断循环 break end # 推进索引 @index += 1 end # 评价 result = eval(script) $arpg_actor.visible = $game_system.arpg_ing unless $arpg_actor.nil? # 返回值为 false 的情况下 if result == false # 结束 @index += 1 #################唯一修改的地方,增加了这行代码 return false end # 继续 return true end
def command_355
# script 设置第一行
script = @list[@index].parameters[0] + "\n"
# 循环
loop do
# 下一个事件指令在脚本 2 行以上的情况下
if @list[@index+1].code == 655
# 添加到 script 2 行以后
script += @list[@index+1].parameters[0] + "\n"
# 事件指令不在脚本 2 行以上的情况下
else
# 中断循环
break
end
# 推进索引
@index += 1
end
# 评价
result = eval(script)
$arpg_actor.visible = $game_system.arpg_ing unless $arpg_actor.nil?
# 返回值为 false 的情况下
if result == false
# 结束
@index += 1 #################唯一修改的地方,增加了这行代码
return false
end
# 继续
return true
end
感谢两位猫斑竹和二楼三位大神的技术贡献,我把代码重新修改了下,只要加了注释行代码,就不会出此BUG了。
(该BUG会在脚本编辑框内仅有一行代码,且代码返回值为false时无限死循环。经过测试,如果脚本编辑框内拥有两行以上的内容,无论最后一行返回结果是不是false都不会死循环。至于原因,猫斑竹的帖子里也给出了答案。) |