Project1
标题:
[简单实用]续行符创建超长文章
[打印本页]
作者:
SailCat
时间:
2007-8-19 08:47
标题:
[简单实用]续行符创建超长文章
本帖最后由 后知后觉 于 2009-11-20 14:11 编辑
没记错的话这是站上第4个长文章脚本了吧。。。。
效果:通过在“显示文章”的事件末尾加上续行符"_",可以实现文章的连续显示,不需要进行特殊设置。最大可以显示12行(超过12行,屏幕也不够用了)
使用方法:将以下脚本插入到Main之前,在需要文章连辍显示的场合,在“显示文章”的文本最后一行末尾处,加入一个空格和一个下划线,例:
显示文章:这是第一行
这是第二行
这是第三行
这是第四行 _
显示文章:这是第五行
这是第六行 _
显示选择项:C1,C2,C3
以上事件在游戏里将会变成一个大文本框,里面有九行,最后三行是选择项
......
注意:
1. 续行符仅写在“显示文章”事件的最后一行末尾才有效果,写在中间行末尾会被直接过滤掉,写在不是行末尾的地方会当作普通字符显示,续行符对后续的“显示文章”“显示选择项”“输入数值”均有收纳作用。
2. 续行符前面必须有一个空格,否则会当作普通字符显示出来且没有效果。
3. 当文章长度已经积累到12行时,续行符失效。
脚本(有完整注释,如果你使用了小字体导致允许显示12行以上的文章,可以修改相应地方):
#============================================================================
# ■ 续行符文章连辍显示 by SailCat
#============================================================================
class Window_Message
alias sailcat_refresh refresh
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
lines = 0
$game_temp.message_text.each {lines += 1}
lines = 4 if lines < 4
self.height = lines * 32 + 32
self.contents = Bitmap.new(width - 32, height - 32)
reset_window
sailcat_refresh
end
#--------------------------------------------------------------------------
# ● 设置窗口位置与不透明度
#--------------------------------------------------------------------------
def reset_window
if $game_temp.in_battle
self.y = 16
else
case $game_system.message_position
when 0 # 上
self.y = 16
when 1 # 中
self.y = 240 - self.height / 2
when 2 # 下
self.y = 464 - self.height
end
end
if $game_system.message_frame == 0
self.opacity = 255
else
self.opacity = 0
end
self.back_opacity = 160
end
end
class Interpreter
#--------------------------------------------------------------------------
# ● 显示文章
#--------------------------------------------------------------------------
def command_101
# 另外的文章已经设置过 message_text 的情况下
if $game_temp.message_text != nil
# 结束
return false
end
# 设置信息结束后待机和返回调用标志
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
# message_text 设置为 1 行
$game_temp.message_text = @list[@index].parameters[0] + "\n"
line_count = 1
# 最大 4 行
line_max = 4
# 循环
loop do
# 下一个事件指令为文章两行以上的情况
if @list[@index+1].code == 401
# message_text 添加到第 2 行以下
$game_temp.message_text += @list[@index+1].parameters[0] + "\n"
line_count += 1
# 下一个事件指令为显示文章,且本行末尾有续行标记的情况
elsif @list[@index+1].code == 101 and @list[@index].parameters[0][-2, 2] == " _"
# 如果已经达到 12 行就返回
if line_count == 12
# 清除续行标记
$game_temp.message_text.gsub!(/ _$/, "")
# 继续
return true
end
# message_text 添加到第 2 行以下
$game_temp.message_text += @list[@index+1].parameters[0] + "\n"
line_count += 1
# 增加 4 行空间,最多 12 行
line_max += 4 if line_max < 12
# 事件指令不在文章两行以下的情况
else
# 如果本行末尾有续行标记则增加到 12 行
if @list[@index].parameters[0][-2, 2] == " _"
line_max = 12
end
# 下一个事件指令为显示选择项的情况下
if @list[@index+1].code == 102
# 如果选择项能收纳在画面里
if @list[@index+1].parameters[0].size <= line_max - line_count
# 推进索引
@index += 1
# 设置选择项
$game_temp.choice_start = line_count
setup_choices(@list[@index].parameters)
end
# 下一个事件指令为处理输入数值的情况下
elsif @list[@index+1].code == 103 or
# 如果数值输入窗口能收纳在画面里
if line_count < line_max
# 推进索引
@index += 1
# 设置输入数值
$game_temp.num_input_start = line_count
$game_temp.num_input_variable_id = @list[@index].parameters[0]
$game_temp.num_input_digits_max = @list[@index].parameters[1]
end
end
# 清除续行标记
$game_temp.message_text.gsub!(/ _$/, "")
# 继续
return true
end
# 推进索引
@index += 1
end
end
end
复制代码
[line]10[/line]
以下内容由 后知后觉 添加:
关于一处BUG的修正请点击
http://rpg.blue/viewthread.php?t ... D%E8%A1%8C%E7%AC%A6
作者:
SailCat
时间:
2007-8-19 08:47
标题:
[简单实用]续行符创建超长文章
本帖最后由 后知后觉 于 2009-11-20 13:55 编辑
重复内容编辑掉
作者:
SailCat
时间:
2007-8-19 08:52
几个说明:
1. 整合的窗口是默认的窗口,如果使用的是增加窗口或fuki的话。。。可能refresh被定义过。。。请自己调试
2. 因为除了这段脚本其他的全都是默认的,就不上传测试工程了
作者:
轮回者
时间:
2007-8-19 20:36
猫大人~{/se}
这个,比那个用全局变量的用起来舒服。
作者:
gpra8764
时间:
2007-8-20 21:12
提示:
作者被禁止或删除 内容自动屏蔽
作者:
K’
时间:
2007-8-20 22:02
发布完毕 VIP += 2
http://rpg.blue/web/htm/news827.htm
如果您对此有何异议请短信告诉我。{/wx}
作者:
xiaoyue06
时间:
2007-8-23 00:46
我试用了这个教本,发现对“显示文章”“显示选择项”确实有收纳,但对“输入数值”好像没有收纳哦。不知道大家试验的结果怎么样。是不是我哪里搞错了?
作者:
lenxi
时间:
2007-8-25 19:59
还真不错,可惜和真·对话框增强精简强化变态版本冲突
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1