解压事件中的脚本:
file=File.open("../__scripts.as","w")
file.write("//本代码是系统自动生成的,请不要修改这些代码\n")
file.write("\n")
file.write("package\n")
file.write("{\n")
file.write(" import RPG.*;\n")
file.write(" public class __scripts\n")
file.write(" {\n")
#file.write(" public var num:int="+$game_scripts.length.to_s+";\n")
file.write(" private var id:int;\n")
file.write(" public var event_id:int=-1;\n")
file.write(" private var fun:Function;\n")
file.write(" public function __scripts(id:int):void\n")
file.write(" {\n")
file.write(" this.id=id;\n")
file.write(" }\n")
file.write(" public function execute():Boolean\n")
file.write(" {\n")
enter_flag=true # 上一条脚本是否换行
for i in 0..$game_scripts.length-1
file.write(" if (this.id=="+i.to_s+")\n")
file.write(" {\n")
file.write(" fun=function():Boolean\n")
file.write(" {\n")
for j in 0..$game_scripts[i].length-1
content=$game_scripts[i][j]
file.write(" ") if enter_flag
file.write(content)
trc=trim(content)
# 下面判断是否该换行
if trc[-1,1]==";" or \
/^[^;]*;[^;]*\/\/.*$/===trc or \
/^\/\//===trc # 开头以“//”开始的脚本视为整行注释
file.write("\n")
enter_flag=true
else
enter_flag=false
end
end
file.write(" return true;\n")
file.write(" };\n")
file.write(" }\n")
end
file.write(" return fun();\n")
file.write(" }\n")
file.write(" }\n")
file.write("}")
file.close()