# fuck coding:utf-8
#==============================================================================
# ● 脚本批量导入导出
#------------------------------------------------------------------------------
# output_scripts : 导出所有脚本到 Scripts 文件夹内
# input_scripts : 导入 Scripts 文件夹内所有文本(.txt)到脚本编辑器, 需重启编辑器
# 导入的文件如果不是 utf-8 编码将会出现乱码.
# 以及 : 没有加特殊识别机能(比如标有★的就导入之类的), 需要者自行添加.= =b..
#==============================================================================
DataName = self.nil? ? "Data/Scripts.rxdata" : (
RUBY_VERSION == '1.9.2' ? "Data/Scripts.rvdata2" : "Data/Scripts.rvdata")
Dir.mkdir("./Scripts") unless FileTest.exist?("./Scripts")
def output_scripts
load_data(DataName).each_with_index do |(num, name, content), index|
name.delete!('/:*?"<>|\\')
File.open("./Scripts/#{index} #{num} #{name}.txt", "w") do |f|
f.puts Zlib::Inflate.inflate(content)
end
end
end
def input_scripts
data = load_data(DataName)
Dir["./Scripts/*.txt"].each do |filename|
num = rand(99999999)
name = File.basename(filename, ".txt")
content = Zlib::Deflate.deflate(File.read(filename))
data << [num, name, content]
end
save_data(data, DataName)
end