函数库:$game_scripts=[] def trim(str) return str if (str.empty?) while str[0,1]==" " or str[0,1]=="\t" str[0,1]="" end while str[-1,1]==" " str[-1,1]="" end return str end # 安全输出字符串 def strfmt(str) str=str.gsub(/\\(\w)/,"\\\\\\\\\\1") str=str.gsub(/"/,"\\\"") str="\""+str+"\"" # 参数0加字符串符号 return str end
# 用于输出事件的执行内容 # 输出执行内容 def eventlist(file,list,script_head) file.write(script_head+".list=new Array();\n") scr_ar=[] for k in 0..list.length-1 l=list[k] next if (l.code==509 || l.code==209) next if (l.code==108 || l.code==408) # 跳过注释 s4=script_head+".list["+k.to_s+"]" file.write(s4+"=new Object();\n") file.write(s4+".code="+l.code.to_s+";\n") file.write(s4+".indent="+l.indent.to_s+";\n") if l.code==355 or l.code==655 # 脚本 file.write(s4+".parameters=["+$game_scripts.length.to_s+"];\n") scr_ar.push(l.parameters[0]) else pars=l.parameters pars[0]=strfmt(pars[0]) if ([101,123,401].include?(l.code)) file.write(s4+".parameters=["+pars.join(",")+"];\n") # 如果还有脚本组未导出 if (scr_ar.length>0) $game_scripts.push(scr_ar) scr_ar=[] end end end end
|