函數庫:$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
|