Project1
标题:
全局文字输出and输入
[打印本页]
作者:
恐惧剑刃
时间:
2014-8-5 18:20
标题:
全局文字输出and输入
本帖最后由 恐惧剑刃 于 2014-8-5 18:24 编辑
本脚本原意解决XP提问区某用户的提问,但存在BUG(已经回避)暂不知解决方法。
不过大体能用,求精简,求BUG解决方法。
替换脚本没有完成(自动换行)!!
#===============================================
# ■ 全局文字输出
#===============================================
#标记常量 前一个为 分隔符 后一为 终止符
#如果翻译,请在 分隔符 与 终止符 之间 完成翻译
#此标记常量不可删除。
TXTSym = "◆◇"
#以下脚本翻译完成后可以删除
#确认输出
ok = true#true
if ok
#确认文章段落是否换行
newline = false#如果翻译建议false,方便输入。
#确认输出地图名称
output_mapname = false#如果翻译建议false,方便输入。
#确认输出事件名称
optput_eventname = false#如果翻译建议false,方便输入。
#确认输出标记符
optput_sym = true#如果翻译建议true,方便输入。
#打开文件
txt = File.open("OutPutText.txt", "w")
#地图名称库
mapname = load_data("Data/MapInfos.rxdata")
#计数器
id = 1
file_count = 0
data = Dir.glob("Data/*")
data = data.size - 15
#检索地图
while id < 999
#结束判断
if file_count >= data
id = 999 ; next
end
#文件名
filename = sprintf("Data/Map%03d.rxdata", id)
#存在判断
next unless FileTest.exist?(filename)
#读取数据
map = load_data(filename)
#写入地图名称
txt.write("————" + mapname[id].name + "————" + "\n") if output_mapname
#检索事件(角色)
for id in map.events.keys.sort
event = map.events[id]
#检索事件页
for page in event.pages
#检索事件条目
for list in page.list
#判断代码
if [101, 401].include?(list.code)
#写入文件
txt.write("【#{event.name}】" + "\n") if list.code == 101 if optput_eventname
txt.write(list.parameters[0])
end
end
#标记
txt.write(TXTSym) if optput_sym
#换行
txt.write("\n") if newline
end
end
#计数器
id += 1
file_count += 1
end
#关闭文件
txt.close
end
复制代码
#===============================================
# ■ 全局文字输入
#===============================================
#设置模块
module TranslationText
#分隔符
sym_1 = TXTSym.split("")[0]
#终止符
sym_2 = TXTSym.split("")[1]
#功能哈希
Arr = {}
#功能字符
str = ""
#输入文本
File.open("InPutText.txt", "r") do |file|#打开txt
#查看每一行
file.readlines.each do |contents|
#添加进String
str << contents
end
end
#回避BUG
for s in 0...(a=str.clone.split("")).size
str = "" if s == 0
str << a[s] if s != 0
end
#分割文章
str.split(sym_2).each do |text|
Arr[text.split(sym_1)[0]] = text.split(sym_1)[1]
end
end
复制代码
#===============================================
# ■ 全局文字替换
#===============================================
# $temp_text = false 使用默认语言
# $temp_text = true 使用第二语言
$temp_text = true
#信息框的类
class Window_Message < Window_Selectable
#重命名
alias refresh_input_text_old refresh
#刷新
def refresh
#判断语言类型
if $temp_text
#拷贝文章
text = $game_temp.message_text.clone
#处理换行字符
text.gsub!("\n") { "" }
#替换
$game_temp.message_text = TranslationText::Arr[text].clone
end
#执行刷新
refresh_input_text_old
end
end
复制代码
作者:
布罗利
时间:
2014-8-7 08:04
什么功能,完全不懂?在什么地方应用?{:2_276:}
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1