#如果行号非空
if line_label != ""
#搜索到指定的行号,直到文件结尾才结束
for @p in [email protected]
#打开下一行文字
t=@t[@p]
#当此行是行号时(左右为匹配的方括号)
if t[0,1] == "[" and t[-2,1] == "]"
#判断是不是要找的行号
if t == "[" + line_label + "]\n"
#是的话说明找到了,停在下行,并退出循环
@p+=1
break
end
end
end
end
#如果行号非空
if line_label != "" and line_label != nil
#搜索到指定的行号,直到文件结尾才结束
for @p in [email protected]
#打开下一行文字
t=@t[@p]
#当此行是行号时(左右为匹配的方括号)
if t[0,1] == "[" and t[-2,1] == "]"
#判断是不是要找的行号
if t == "[" + line_label + "]\n"
#是的话说明找到了,停在下行,并退出循环
@p+=1
break
end
end
end
end
#设定变量
@line_label = line_label
@is_open = true
end
return(true)
end
#--------------------------------------------------------------------------
# ● 关闭文件
#--------------------------------------------------------------------------
def close
@txt_file.close
@is_open=false
end
#--------------------------------------------------------------------------
# ● 获取文字色
# n : 文字色编号 (0~7)
#--------------------------------------------------------------------------
def text_color(n)
case n
when 0
return Color.new(255, 255, 255, 255)
when 1
return Color.new(128, 128, 255, 255)
when 2
return Color.new(255, 128, 128, 255)
when 3
return Color.new(128, 255, 128, 255)
when 4
return Color.new(128, 255, 255, 255)
when 5
return Color.new(255, 128, 255, 255)
when 6
return Color.new(255, 255, 128, 255)
when 7
return Color.new(192, 192, 192, 255)
else
normal_color
end
end
#--------------------------------------------------------------------------
# ● 获取普通文字色
#--------------------------------------------------------------------------
def normal_color
return Color.new(255, 255, 255, 255)
end
#--------------------------------------------------------------------------
# ● 获取无效文字色
#--------------------------------------------------------------------------
def disabled_color
return Color.new(255, 255, 255, 128)
end
#--------------------------------------------------------------------------
# ● 获取系统文字色
#--------------------------------------------------------------------------
def system_color
return Color.new(192, 224, 255, 255)
end
#--------------------------------------------------------------------------
# ● 获取危机文字色
#--------------------------------------------------------------------------
def crisis_color
return Color.new(255, 255, 64, 255)
end
#--------------------------------------------------------------------------
# ● 获取战斗不能文字色
#--------------------------------------------------------------------------
def knockout_color
return Color.new(255, 64, 0)
end
#--------------------------------------------------------------------------
# ● 生成描绘用的状态字符串
# actor : 角色
# width : 描画目标的宽度
# need_normal : [正常] 是否为必须 (true / false)
#--------------------------------------------------------------------------
def make_battler_state_text(battler, width, need_normal)
# 获取括号的宽
brackets_width = self.contents.text_size("[]").width
# 生成状态名字符串
text = ""
for i in battler.states
if $data_states.rating >= 1
if text == ""
text = $data_states.name
else
new_text = text + "/" + $data_states.name
text_width = self.contents.text_size(new_text).width
if text_width > width - brackets_width
break
end
text = new_text
end
end
end
# 状态名空的字符串是 "[正常]" 的情况下
if text == ""
if need_normal
text = "[正常]"
end
else
# 加上括号
text = "[" + text + "]"
end
# 返回完成后的文字类
return text
end
#--------------------------------------------------------------------------
# ● 读入一行文字,文件已结束返回"[END]"
#--------------------------------------------------------------------------
def get_text(len=4)
t="" # 临时变量
s="" # 返回值
l=0 # 已打开的行数
#如果文件已经关闭,直接返回结束标志
if !@is_open
return("\\~\\/[END]")
end
#如果文件已经读到了末尾
if @p>[email protected]
#关闭文件
@txt_file.close
#设置标志变量
@is_open = false
#返回结束标志
return("\\~\\/[END]")
end
#打开一行文字
t=@t[@p]
#读入字符串,终止条件是文件结束、遇到行号或者已经打开需要行数的文字
while l<len
#否则的话就加入到字符串s末尾
s = s + t
#l自增
l += 1
#@p自增
@p += 1
#打开一行文字
t=@t[@p]
#当下行是行号(左右为匹配的方括号)或者已经结束时退出,否则就会进入下次循环
if t==nil or (t[0,1] == "[" and t[-2,1] == "]")
#加入"[END]"到字符串s末尾
s = s + "[END]"
#关闭文件
@txt_file.close
#设置标志变量
@is_open = false
#终止循环
break
end
end
if s.size > 0
#字符串非空的时候返回字符串
return s
else
#否则可能是文件结束了所以返回结束标志
return "\\~\\/[END]"
end
end
end
我希望这个脚本能够在读取txt文本后能识别/v[]之类的语言。作者: 芯☆淡茹水 时间: 2015-3-7 20:56
/v 之类的啥? 显示变量值?