Advertisement
KananGamer

[TFM] Load script by map

Oct 1st, 2019
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 32.52 KB | None | 0 0
  1. --[[ Require By: Nettoork#0000 ]]--
  2. do local a={}local b={}local c={}local d={}local e={"eventChatCommand ","eventChatMessage","eventEmotePlayed","eventFileLoaded","eventFileSaved","eventKeyboard","eventMouse","eventLoop","eventNewGame","eventNewPlayer","eventPlayerDataLoaded","eventPlayerDied","eventPlayerGetCheese","eventPlayerLeft","eventPlayerVampire","eventPlayerWon","eventPlayerRespawn","eventPlayerMeep","eventPopupAnswer","eventSummoningStart","eventSummoningCancel","eventSummoningEnd","eventTextAreaCallback","eventColorPicked"}local f;f={['perfomance']={AUTHOR='Nettoork#0000',_VERSION='1.0',dependencies={},['create']=function(g,h,i)local j=0;for v=1,g do local k=os.time()for l=1,h do i(h)end;j=j+os.time()-k end;return'Estimated Time: '..j/g..' ms.'end},['button']={AUTHOR='Nettoork#0000',_VERSION='1.0',dependencies={},['create']=function(...)local m={...}local n=-543212345+m[1]*3;local o=m[9]and'0x2A424B'or'0x314e57'ui.addTextArea(n,'',m[4],m[5]-1,m[6]-1,m[7],m[8],0x7a8d93,0x7a8d93,1,true)ui.addTextArea(n-1,'',m[4],m[5]+1,m[6]+1,m[7],m[8],0x0e1619,0x0e1619,1,true)ui.addTextArea(n-2,'<p align="center"><a href="event:'..m[3]..'">'..m[2]..'</a></p>',m[4],m[5],m[6],m[7],m[8],o,o,1,true)end,['remove']=function(n,p)for l=0,2 do ui.removeTextArea(-543212345+n*3-l,p)end end},['ui-design']={AUTHOR='Nettoork#0000',_VERSION='1.0',dependencies={},['create']=function(...)local m={...}if m[6]<0 or m[7]and m[7]<0 then return elseif not m[7]then m[7]=m[6]/2 end;local n=543212345+m[1]*8;ui.addTextArea(n,'',m[3],m[4],m[5],m[6]+100,m[7]+70,0x78462b,0x78462b,1,true)ui.addTextArea(n+1,'',m[3],m[4],m[5]+(m[7]+140)/4,m[6]+100,m[7]/2,0x9d7043,0x9d7043,1,true)ui.addTextArea(n+2,'',m[3],m[4]+(m[6]+180)/4,m[5],(m[6]+10)/2,m[7]+70,0x9d7043,0x9d7043,1,true)ui.addTextArea(n+3,'',m[3],m[4],m[5],20,20,0xbeb17d,0xbeb17d,1,true)ui.addTextArea(n+4,'',m[3],m[4]+m[6]+80,m[5],20,20,0xbeb17d,0xbeb17d,1,true)ui.addTextArea(n+5,'',m[3],m[4],m[5]+m[7]+50,20,20,0xbeb17d,0xbeb17d,1,true)ui.addTextArea(n+6,'',m[3],m[4]+m[6]+80,m[5]+m[7]+50,20,20,0xbeb17d,0xbeb17d,1,true)ui.addTextArea(n+7,m[2],m[3],m[4]+3,m[5]+3,m[6]+94,m[7]+64,0x1c3a3e,0x232a35,1,true)end,['remove']=function(n,p)for l=0,7 do ui.removeTextArea(543212345+n*8+l,p)end end},['text-area-custom']={AUTHOR='Nettoork#0000',_VERSION='2.0',dependencies={},['add']=function(...)local q={...}if type(q[1])=='table'then for l,v in next,q do if type(v)=='table'then if not v[3]then v[3]='nil'end;addTextArea(table.unpack(v))end end else if not q[3]then q[3]='nil'end;b[q[3]..'_'..q[1]]={...}ui.addTextArea(...)end end,['update']=function(n,r,p)if not p then p='nil'end;if not b[p..'_'..n]then return elseif type(r)=='string'then ui.updateTextArea(n,r,p)b[p..'_'..n][2]=r;return end;local s={text=2,x=4,y=5,w=6,h=7,background=8,border=9,alpha=10,fixed=11}for l,v in next,r do if s[l]then b[p..'_'..n][s[l]]=v end end;local t=b[p..'_'..n]ui.addTextArea(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11])end,['remove']=function(n,p)if not p then p='nil'end;if b[p..'_'..n]then b[p..'_'..n]=nil end;ui.removeTextArea(n,p)end},['string-to-boolean']={AUTHOR='Nettoork#0000',_VERSION='1.0',dependencies={},['parse']=function(u)local w={}for l,v in next,u do w[v]=true end;return w end},['database']={AUTHOR='Nettoork#0000',_VERSION='1.1',dependencies={},['create']=function(x,y)if not c[x]then c[x]=y end end,['delete']=function(x)c[x]=nil end,['get']=function(x,...)local z,A={},{...}if not A[1]then return c[x]else for l,v in next,A do if c[x][v]then z[#z+1]=c[x][v]end end;return table.unpack(z)end end,['set']=function(x,...)local B=v;for l,v in next,{...}do if not B then B=v else c[x][B]=v;B=false end end end},['encryption']={AUTHOR='Nettoork#0000',_VERSION='1.0',dependencies={},['encrypt']=function(u,C,D)if not u or not C or not D or type(u)~='table'or C==''or D==''then return end;local E,F,G,H='','','',''for l in C:gmatch('.')do E=E..l:byte()end;for l in D:gmatch('.')do H=H..l:byte()end;math.randomseed(E)otherSeed=math.random(1000000)local I=pcall(function()for l,v in next,u do if type(v)=='string'or type(v)=='number'then if type(v)=='string'then v="'"..v.."'"end;G=G..' '..v..' '..l:upper()else return end end;G=G..' '..H;for l in G:gmatch('.')do local J=l:byte()+68+math.random(5)otherSeed=otherSeed+l:byte()math.randomseed(otherSeed)if J>=65 and J<=122 and not(J>=91 and J<=96)then J=string.char(J)end;F=F..J end end)math.randomseed(os.time())if not I then return else return F end end,['decrypt']=function(K,C,D)if not K or not C or not D or type(K)~='string'or C==''or D==''then return end;local E,F,L,H='','','',''for l in C:gmatch('.')do E=E..l:byte()end;for l in D:gmatch('.')do H=H..l:byte()end;math.randomseed(E)otherSeed=math.random(1000000)local I=pcall(function()for l in K:gmatch('.')do if l:byte()>=65 and l:byte()<=122 then local J=l:byte()-68-math.random(5)otherSeed=otherSeed+J;math.randomseed(otherSeed)F=F..string.char(J)else L=L..l;if L:len()>=3 then local J=tonumber(L)-68-math.random(5)otherSeed=otherSeed+J;math.randomseed(otherSeed)F=F..string.char(J)L=''end end end end)math.randomseed(os.time())if not I then return else local w,M,N,O,P={},0,0;for l,v in string.gmatch(F,'[^%s]+')do N=N+1 end;for l,v in string.gmatch(F,'[^%s]+')do M=M+1;if M==N and l~=H then return elseif O then if O:sub(-1)=="'"then w[l:lower()]=O:gsub("'",'')O=nil else O=O..' '..l end elseif P then w[l:lower()]=P;P=nil elseif l:sub(1,1)=="'"then O=l else P=l end end;return w end end},['sleep']={AUTHOR='Nettoork#0000',_VERSION='1.1',dependencies={},['loop']=function()local Q={}for l,v in next,a do if not v[2]or v[2]<os.time()then if coroutine.status(v[1])=='dead'then Q[#Q+1]=l else local R,S=coroutine.resume(v[1])v[2]=S end end end;if Q[1]then for l,v in next,Q do a[v]=nil end end end,['run']=function(T,U)if not U then U=500 end;a[#a+1]={coroutine.create(function()local V=function(W)coroutine.yield(os.time()+math.floor(W/U)*U)end;T(V)end),timeValue=nil}end},['wait-time']={AUTHOR='Nettoork#0000',_VERSION='1.0',dependencies={},['check']=function(X,Y,Z,_)if X and Y then if not d[X]then d[X]={}end;if not d[X][Y]then _=0;d[X][Y]=os.time()+(Z or 1000)end;if d[X][Y]<=os.time()or _ and _==0 then d[X][Y]=os.time()+(Z or 1000)return true else return false end end end},['json']={AUTHOR='https://github.com/rxi',_VERSION='0.1.1',dependencies={},['encode']=function(a0)local a1;local a2={["\\"]="\\\\",["\""]="\\\"",["\b"]="\\b",["\f"]="\\f",["\n"]="\\n",["\r"]="\\r",["\t"]="\\t"}local a3={["\\/"]="/"}for a4,v in pairs(a2)do a3[v]=a4 end;local function a5(a6)return a2[a6]or string.format("\\u%04x",a6:byte())end;local function a7(a0)return"null"end;local function a8(a0,a9)local aa={}a9=a9 or{}if a9[a0]then error("circular reference")end;a9[a0]=true;if a0[1]~=nil or next(a0)==nil then local W=0;for a4 in pairs(a0)do if type(a4)~="number"then error("invalid table: mixed or invalid key types")end;W=W+1 end;if W~=#a0 then error("invalid table: sparse array")end;for l,v in ipairs(a0)do table.insert(aa,a1(v,a9))end;a9[a0]=nil;return"["..table.concat(aa,",").."]"else for a4,v in pairs(a0)do if type(a4)~="string"then error("invalid table: mixed or invalid key types")end;table.insert(aa,a1(a4,a9)..":"..a1(v,a9))end;a9[a0]=nil;return"{"..table.concat(aa,",").."}"end end;local function ab(a0)return'"'..a0:gsub('[%z\1-\31\\"]',a5)..'"'end;local function ac(a0)if a0~=a0 or a0<=-math.huge or a0>=math.huge then error("unexpected number value '"..tostring(a0).."'")end;return a0 end;local ad={["nil"]=a7,["table"]=a8,["string"]=ab,["number"]=ac,["boolean"]=tostring}a1=function(a0,a9)local ae=type(a0)local T=ad[ae]if T then return T(a0,a9)end;error("unexpected type '"..ae.."'")end;return a1(a0)end,['decode']=function(af)local ag;local a3={["\\/"]="/"}local function ah(...)local aa={}for l=1,select("#",...)do aa[select(l,...)]=true end;return aa end;local ai=ah(" ","\t","\r","\n")local aj=ah(" ","\t","\r","\n","]","}",",")local ak=ah("\\","/",'"',"b","f","n","r","t","u")local al=ah("true","false","null")local am={["true"]=true,["false"]=false,["null"]=nil}local function an(af,ao,ap,aq)for l=ao,#af do if ap[af:sub(l,l)]~=aq then return l end end;return#af+1 end;local function ar(af,ao,as)local at=1;local au=1;for l=1,ao-1 do au=au+1;if af:sub(l,l)=="\n"then at=at+1;au=1 end end;error(string.format("%s at line %d col %d",as,at,au))end;local function av(W)local T=math.floor;if W<=0x7f then return string.char(W)elseif W<=0x7ff then return string.char(T(W/64)+192,W%64+128)elseif W<=0xffff then return string.char(T(W/4096)+224,T(W%4096/64)+128,W%64+128)elseif W<=0x10ffff then return string.char(T(W/262144)+240,T(W%262144/4096)+128,T(W%4096/64)+128,W%64+128)end;error(string.format("invalid unicode codepoint '%x'",W))end;local function aw(R)local ax=tonumber(R:sub(3,6),16)local ay=tonumber(R:sub(9,12),16)if ay then return av((ax-0xd800)*0x400+ay-0xdc00+0x10000)else return av(ax)end end;local function az(af,l)local aA=false;local aB=false;local aC=false;local aD;for aE=l+1,#af do local aF=af:byte(aE)if aF<32 then ar(af,aE,"control character in string")end;if aD==92 then if aF==117 then local aG=af:sub(aE+1,aE+5)if not aG:find("%x%x%x%x")then ar(af,aE,"invalid unicode escape in string")end;if aG:find("^[dD][89aAbB]")then aB=true else aA=true end else local a6=string.char(aF)if not ak[a6]then ar(af,aE,"invalid escape char '"..a6 .."' in string")end;aC=true end;aD=nil elseif aF==34 then local R=af:sub(l+1,aE-1)if aB then R=R:gsub("\\u[dD][89aAbB]..\\u....",aw)end;if aA then R=R:gsub("\\u....",aw)end;if aC then R=R:gsub("\\.",a3)end;return R,aE+1 else aD=aF end end;ar(af,l,"expected closing quote for string")end;local function aH(af,l)local aF=an(af,l,aj)local R=af:sub(l,aF-1)local W=tonumber(R)if not W then ar(af,l,"invalid number '"..R.."'")end;return W,aF end;local function aI(af,l)local aF=an(af,l,aj)local aJ=af:sub(l,aF-1)if not al[aJ]then ar(af,l,"invalid literal '"..aJ.."'")end;return am[aJ],aF end;local function aK(af,l)local aa={}local W=1;l=l+1;while 1 do local aF;l=an(af,l,ai,true)if af:sub(l,l)=="]"then l=l+1;break end;aF,l=ag(af,l)aa[W]=aF;W=W+1;l=an(af,l,ai,true)local aL=af:sub(l,l)l=l+1;if aL=="]"then break end;if aL~=","then ar(af,l,"expected ']' or ','")end end;return aa,l end;local function aM(af,l)local aa={}l=l+1;while 1 do local H,a0;l=an(af,l,ai,true)if af:sub(l,l)=="}"then l=l+1;break end;if af:sub(l,l)~='"'then ar(af,l,"expected string for key")end;H,l=ag(af,l)l=an(af,l,ai,true)if af:sub(l,l)~=":"then ar(af,l,"expected ':' after key")end;l=an(af,l+1,ai,true)a0,l=ag(af,l)aa[H]=a0;l=an(af,l,ai,true)local aL=af:sub(l,l)l=l+1;if aL=="}"then break end;if aL~=","then ar(af,l,"expected '}' or ','")end end;return aa,l end;local aN={['"']=az,["0"]=aH,["1"]=aH,["2"]=aH,["3"]=aH,["4"]=aH,["5"]=aH,["6"]=aH,["7"]=aH,["8"]=aH,["9"]=aH,["-"]=aH,["t"]=aI,["f"]=aI,["n"]=aI,["["]=aK,["{"]=aM}ag=function(af,ao)local aL=af:sub(ao,ao)local T=aN[aL]if T then return T(af,ao)end;ar(af,ao,"unexpected character '"..aL.."'")end;if type(af)~="string"then error("expected argument of type string, got "..type(af))end;local aa,ao=ag(af,an(af,1,ai,true))ao=an(af,ao,ai,true)if ao<=#af then ar(af,ao,"trailing garbage")end;return aa end},['runtime-analyze']={AUTHOR='Nettoork#0000',_VERSION='1.0',dependencies={},['run']=function(...)local aO=0;local aP=0;local aQ=0;local aR={}local aS={...}local aT={}local aU={"#83FFA4","#30FF67","#00FF44","#E9FF82","#EEFF24","#F5F604","#FF524F","#FF302D","#E60400","#C70502"}for l=1,10 do aT[l]=string.rep("\226\150\136",l)end;if tfm.get.room.name:find("^\42\03")~=nil then aQ=40 else aQ=60 end;local aV=function()local aW=""for l,v in next,aR do local aX=math.floor(v.timeLoaded/(aQ/10))*(5-math.floor(aO/2))aX=aX>10 and 10 or aX;local aY=(aX==0 and""or"<font color='"..aU[aX].."'>")..(aX==0 and""or aT[aX])aW=aW..string.format("<PT>[%s]</PT>\n%dms %s",l,v.timeLoaded,aY)..'</font>\n'end;local aX=math.floor(aP/(aQ/10))*(5-math.floor(aO/2))aX=aX>10 and 10 or aX;local aY=(aX==0 and""or"<font color='"..aU[aX].."'>")..(aX==0 and""or aT[aX])aW=aW..string.format("<D>Global Runtime:</D>\n%dms %s",aP,aY)..'</font> '..aQ..'ms\n'if aS[1]then for l,v in next,aS do ui.addTextArea(3102301909,aW,v,5,26,0,0,1,1,0.5,true)end else ui.addTextArea(3102301909,aW,nil,5,26,0,0,1,1,0.5,true)end end;local aZ={['eventLoop']=function()aO=aO+1;if aO>8 then aP=0;aO=0;for l,v in next,aR do aR[l]={call=0,timeLoaded=0}end end;aV()end}for l,v in next,e do if _G[v]and type(_G[v])=="function"then local a_=_G[v]if not aR[v]then aR[v]={call=0,timeLoaded=0}end;_G[v]=function(...)aR[v].call=aR[v].call+1;if aZ[v]then aZ[v](table.unpack({...}))end;local b0=os.time()a_(table.unpack({...}))local b1=os.time()-b0;aP=aP-aR[v].timeLoaded;aR[v].timeLoaded=aR[v].timeLoaded+b1+b1*0.15;aP=aP+aR[v].timeLoaded end else if aZ[v]then _G[v]=aZ[v]end end end end},['parse-xml']={AUTHOR='http://lua-users.org/wiki/LuaXml',_VERSION='1.0',dependencies={},['parse']=function(b2)local a9={}local b3={}table.insert(a9,b3)local b4,a6,b5,b6,b7;local l,aE=1,1;while true do b4,aE,a6,b5,b6,b7=string.find(b2,"<(%/?)([%w:]+)(.-)(%/?)>",l)if not b4 then break end;local b8=string.sub(b2,l,b4-1)if not string.find(b8,"^%s*$")then table.insert(b3,b8)end;local m={}string.gsub(b6,"([%-%w]+)=([\"'])(.-)%2",function(b9,ba,bb)m[b9]=bb end)if b7=="/"then table.insert(b3,{label=b5,xarg=m,empty=1})elseif a6==""then b3={label=b5,xarg=m}table.insert(a9,b3)else local bc=table.remove(a9)b3=a9[#a9]if#a9<1 then error("nothing to close with "..b5)end;if bc.label~=b5 then error("trying to close "..bc.label.." with "..b5)end;table.insert(b3,bc)end;l=aE+1 end;local b8=string.sub(b2,l)if not string.find(b8,"^%s*$")then table.insert(a9[#a9],b8)end;if#a9>1 then error("unclosed "..a9[#a9].label)end;return a9[1]end},['foreach-index']={AUTHOR='https://stackoverflow.com/users/68204/rberteig',_VERSION='1.0',dependencies={},['run']=function(ae,T,bd)local be={}for a4,ba in next,ae do be[#be+1]=a4 end;table.sort(be,bd)for ba,a4 in ipairs(be)do T(a4,ae[a4])end end}}local bf=1547917483395+2628*10^6;require=function(bg)if bg=='hide-warning'then bf=false else if bf and os.time()>bf then bf=false;print("<R>Warning! You may be using an outdated version of require, check in <i>pastebin.com/u/KananGamer</i> if this has a better version, otherwise you can disable this warning with require('hide-warning').</R>")end;if f[bg]then if f[bg]['INIT_SCRIPT']and type(f[bg]['INIT_SCRIPT'])=='function'then f[bg]['INIT_SCRIPT']()f[bg]['INIT_SCRIPT']=nil end;return f[bg]else print('Library "'..bg..'" not found! <i>Require Version: 1.3.0 | Author: Nettoork#0000</i>')return false end end end end
  3. --[[ Current Version: 1.3.0 ]]--
  4.  
  5. local old_G = {}
  6. for i, v in next, _G do
  7.     old_G[i] = v
  8. end
  9.  
  10. old_G.system.giveEventGift = nil
  11. old_G.system.loadFile = nil
  12. old_G.system.loadPlayerData = nil
  13. old_G.system.saveFile = nil
  14. old_G.system.savePlayerData = nil
  15. old_G.tfm.exec.giveConsumables = nil
  16. old_G.print = function(m) tfm.exec.chatMessage('<B><D>[PRINT]</D></B> '..m); end
  17.  
  18. local luayan=function()local b,c,d,e,f,g=string.match,string.sub,string.gsub,string.gmatch,string.char,string.rep;local h=math.max;local i=function(...)local j={...}local k,l={},tonumber(j[2])and j[2]or 0;for m,o in next,j[1]do if l<=m then while l<m do k[#k+1]=nil;l=l+1 end;k[#k+1]=o end end;return k[1],k[2],k[3],k[4],k[5],k[6],k[7],k[8],k[9],k[10],k[11],k[12],k[13],k[14],k[15],k[16],k[17],k[18],k[19],k[20]end;local p;local function q(r,s)return setmetatable({["*parentDefined"]=setmetatable(s or{},{__index=r["*parentDefined"]}),["*nil"]={},["*parent"]=r},{__index=s and function(t,u)if not t["*nil"][u]then if t["*parentDefined"][u]then return r[u]else return p[u]end end end or function(t,u)if not t["*nil"][u]then return r[u]end end,__newindex=function(t,v,w)rawset(t,v,w)if w==nil then t["*nil"][v]=true else t["*nil"][v]=nil end end})end;local function x(r)local s={}for m in next,r do s[m]=true end;for m in next,r["*nil"]do s[m]=true end;return s end;local function y(t,u,w,z)if t==z then while t~=p do if rawget(t,u)~=nil or t["*nil"][u]then break else t=t["*parent"]end end end;t[u]=w end;local A,B={},{}local C={["or"]=function(D,j)return D or j end,["and"]=function(D,j)return D and j end,["<"]=function(D,j)return D<j end,[">"]=function(D,j)return D>j end,["<="]=function(D,j)return D<=j end,[">="]=function(D,j)return D>=j end,["~="]=function(D,j)return D~=j end,["=="]=function(D,j)return D==j end,[".."]=function(D,j)return D..j end,["+"]=function(D,j)return D+j end,["-"]=function(D,j)return D-j end,["*"]=function(D,j)return D*j end,["/"]=function(D,j)return D/j end,["//"]=function(D,j)return math.floor(D/j)end,["%"]=function(D,j)return D%j end,["^"]=function(D,j)return D^j end}local E={"(.*%d)(or)(%d.*)","(.*%d)(and)(%d.*)","(.*%d)([<>~=]=?)(%d.*)","(.*%d)(%.%.)(%d.*)","(.*%d)([%+%-])(%d.*)","(.*%d)([%*/%%]/?)(%d.*)","(.*%d)(%^)(%d.*)"}local F={"^%s*([%+%-%*/%%%^=~><%.][=/%.]?)()","^%s*(and)()[^_%w]","^%s*(or)()[^_%w]"}local G={["#"]=function(D)return#D end,["-"]=function(D)return-D end,["not"]=function(D)return not D end}local H="([#%-])"local I={"%^"}local J={["="]=function(z,K,w)return w end,["+="]=function(z,K,w)return z[K]+w end,["-="]=function(z,K,w)return z[K]-w end,["*="]=function(z,K,w)return z[K]*w end,["/="]=function(z,K,w)return z[K]/w end,["^="]=function(z,K,w)return z[K]^w end,["%="]=function(z,K,w)return z[K]%w end,["..="]=function(z,K,w)return z[K]..w end,["or="]=function(z,K,w)return z[K]or w end,["and="]=function(z,K,w)return z[K]and w end,["//="]=function(z,K,w)return math.floor(z[K]/w)end}local function L(M)M=d(M,"\\(.)(%d?%d?)",function(D,j)if D=="a"then return"\a"..j elseif D=="b"then return"\b"..j elseif D=="f"then return"\f"..j elseif D=="n"then return"\n"..j elseif D=="r"then return"\r"..j elseif D=="t"then return"\t"..j elseif D=="v"then return"\v"..j elseif D=="\\"then return"\\"..j elseif D=="\""then return"\""..j elseif D=="'"then return"'"..j elseif D=="["then return"["..j elseif D=="]"then return"]"..j elseif b(D,"^%d$")then return f(tonumber(D..j))else error("invalid escape sequence")end end)return M end;local function N(O)while true do local P=b(O,"^[^\"']-%[(=-)%[")or b(O,"^[^']-(\")")or b(O,"'")if P then local Q;if P~='"'and P~="'"then Q=b(O,"%["..P.."%[.-%]"..P.."%]()")else local R;R,Q=b(O,P.."(.-)"..P.."()")if Q then local S=0;repeat R=L(R.."0")if c(R,-1)==f(0)then S=S+1;R,Q=b(O,P..'(.-'..g(P..'.-',S)..')'..P..'()')else break end until false end end;if Q then O=c(O,Q)else return P end else return false end end end;local function T(O)local n=1;while true do local U=c(O,n)local V,W=b(U,"()%-%-(%[?=-%[?)")if V then local P=N(c(U,1,V-1))if not P then local j=b(W,"%[(=-)%[")if j then O=c(O,1,n-1)..d(U,"%-%-%["..j.."%[.-%]"..j.."%]"," ",1)else O=c(O,1,n-1)..d(U,"%-%-.-\r?\n"," ",1)end else local X,Y,R=c(U,V)if P=="'"or P=='"'then R,Y=b(X,"(.-)"..P.."()")local S=0;repeat R=L(R.."0")if c(R,-1)==f(0)then S=S+1;R,Y=b(X,'(.-'..g(P..'.-',S)..')'..P..'()')else break end until false else Y=b(X,"%]"..P.."%]()")end;n=n+V+Y-2 end else break end end;return O end;local function Z(_,...)return function(...)local D={_(...)}if D[1]then return D[1],D end end,...end;local function a0(O)local a1,n=b(O,"^%s*([_%a][_%w]*)()")if a1 then O=c(O,n)end;return O,a1 end;local a2,a3;local function a4(a5,z)local S=0;local n,a6,a7,a8=b(a5,"^%s*{()%s*(}?)()")local w={}while a6==""do if a8==""then error("error")end;a5=c(a5,n)n=b(a5,"^%s*%[()")local u,a9;if n then a5,u=a2(c(a5,n),z)n=b(a5,"^%s*%]%s*=%s*()")else u,n=b(a5,"^%s*([_%a][_%w]*)%s*=%s*()")if not n then S=S+1;u=S;n=1 end end;local aa={a2(c(a5,n),z)}a5=aa[1]if z then w[u]=aa[2]if n==1 then local ab=S;for m=3,#aa do ab=ab+1;w[ab]=aa[m]end;for m=ab+1,#w do w[m]=nil end end end;a8,n,a6,a7=b(a5,"^%s*(,?)()%s*(}?)()")end;return c(a5,a7),w end;local function ac(O,ad)local ae=a3(O,nil,"",true)local af=c(O,1,ae)O=c(O,ae+(ad or 3)+1)return O,af end;local function ag(w,z,ah,ai,aj)local n;for m=1,#E do w,n=d(w,E[m],function(D,ak,j)aj=aj+1;ah[aj]=C[ak](ag(D,z,ah,ai,aj),ag(j,z,ah,ai,aj))return tostring(aj)end)if n~=0 then break end end;local m=tonumber(b(w,"%d+"))if ai[m]then ah[m]=select(2,a2(ai[m],z))ai[m]=nil end;return ah[m]end;function a2(O,z,al,am)local w,an,ao,ap;if am then w=am;ap=true else w={}local a1;O,a1=a0(O)if a1 then if a1=="function"then local aq,n,af=b(O,"^%s*%((.-)%)()")if not aq then error("error")end;O,af=ac(c(O,n))if z then local s=x(z)w[1]=function(...)local r=q(z,s)local ar,S,as={...},0,false;for at in e(aq,"%s*([^,]+)%s*")do if as then error("error")end;S=S+1;if at=="..."then r["..."]={i(ar,S,select("#",...))}as=true else r[at]=ar[S]end end;return a3(af,r,"function")end end elseif G[a1]then O,w[1]=a2(O,z,true)if z then w[1]=G[a1](w[1])end elseif a1=="true"then w[1]=true elseif a1=="false"then w[1]=false elseif a1=="nil"then w[1]=nil else if z then w[1]=z[a1]end;ap=true end else local n;w[1],n=b(O,"^%s*\"(.-)\"()")if n then local S=0;repeat w[1]=L(w[1].."0")if c(w[1],-1)==f(0)then S=S+1;w[1],n=b(O,'^%s*"(.-'..g('".-',S)..')"()')else break end until false;w[1]=c(w[1],1,-2)O=c(O,n)else w[1],n=b(O,"^%s*'(.-)'()")if n then local S=0;repeat w[1]=L(w[1].."0")if c(w[1],-1)==f(0)then S=S+1;w[1],n=b(O,'^%s*\'(.-'..g('\'.-',S)..')\'()')else break end until false;w[1]=c(w[1],1,-2)O=c(O,n)else local au;au,w[1],n=b(O,'^%s*%[(=-)%[(.-)%]%1%]()')if n then w[1],n=b(O,'^%s*%['..au..'%[(.-)%]'..au..'%]()')O=c(O,n)else local av,V,n=b(O,"^%s*(%.?)(%d+)()")if V then O=c(O,n)if av==""then local Y,n=b(O,"^%s*%.(%d+)()")if Y then O=c(O,n)V=V.."."..Y else Y,n=b(O,"^%s*x(%w+)()")if Y then if V~="0"then error("error")end;O=c(O,n)V=V.."x"..Y end end;w[1]=tonumber(V)else w[1]=tonumber("0."..V)end else n=b(O,"^%s*%(()")if n then O,w[1]=a2(c(O,n),z)n=b(O,"^%s*%)()")O=c(O,n)ap=true elseif b(O,"^%s*{")then O,w[1]=a4(O,z)else n=b(O,"^%s*%.%.%.()")if n then O=c(O,n)if z then if not z["..."]then error("error")end;w=z["..."]end else local ak,n=b(O,"^%s*"..H.."()")if n then if not G[ak]then error("error")end;O,w[1]=a2(c(O,n),z,true)if z then w[1]=G[ak](w[1])end else error("unexpected character")end end end end end end end end end;while ap do ao=true;local at,n;if b(O,"^%s*{")then O,at=a4(O,z)if z then if an then w={w[1](an,at)}else w={w[1](at)}end end;an=false else at,n=b(O,"^%s*\"(.-)\"()")if at then local S=0;repeat at=L(at.."0")if c(at,-1)==f(0)then S=S+1;at,n=b(O,'^%s*"(.-'..g('".-',S)..')"()')else break end until false;at=c(at,1,-2)O=c(O,n)if z then if an then w={w[1](an,at)}else w={w[1](at)}end end;an=false else at,n=b(O,"^%s*'(.-)'()")if at then local S=0;repeat at=L(at.."0")if c(at,-1)==f(0)then S=S+1;at,n=b(O,'^%s*\'(.-'..g('\'.-',S)..')\'()')else break end until false;at=c(at,1,-2)O=c(O,n)if z then if an then w={w[1](an,at)}else w={w[1](at)}end end;an=false else local au;au,at,n=b(O,'^%s*%[(=-)%[(.-)%]%1%]()')if at then O=c(O,n)if z then if an then w={w[1](an,at)}else w={w[1](at)}end end;an=false elseif b(O,"^%s*%(")then local n=b(O,"^%s*%(%s*%)()")if n then O=c(O,n)if z then if an then w={w[1](an)}else w={w[1]()}end end else local aw,ab={},0;if an then ab=1;aw[ab]=an end;n=b(O,"^%s*%(()")while n do local aa={a2(c(O,n),z)}O=aa[1]ab=ab+1;local S=ab;for m=2,#aa do aw[S]=aa[m]S=S+1 end;for m=S,#aw do aw[m]=nil end;n=b(O,"^%s*,()")end;if z then w={w[1](i(aw))}end;n=b(O,"^%s*%)()")O=c(O,n)end;an=false else if an then error("error")end;n=b(O,"^%s*%[()")if n then local u;O,u=a2(c(O,n),z)n=b(O,"^%s*%]()")O=c(O,n)if z then w[1]=w[1][u]end;ao=false else local ax;ax,n=b(O,"^%s*%.%s*([_%a][_%w]*)()")if n then O=c(O,n)if z then w[1]=w[1][ax]end;ao=false else ax,n=b(O,"^%s*:%s*([_%a][_%w]*)()")if n then O=c(O,n)if z then an=w[1]w[1]=w[1][ax]else an=true end;ao=false else break end end end end end end end end;if am then if not ao then error("error")end;return O end;local n=b(O,"^%s*;()")if n then return c(O,n),i(w)end;if am then if not ao then error("error")end;return O end;if not al then local ah,S,ay,az,ai={w[1]},1,true,"1",{}while ay do ay=false;for m=1,#F do local ak,n=b(O,F[m])if ak then if not C[ak]then error("error")end;ay=true;local aA,aB=c(O,n)O=a2(aA,nil,true)aB=c(aA,1,#aA-#O)S=S+1;ai[S]=aB;if z then az=az..ak..S end;break end end end;if z and az~="1"then w={ag(az,z,ah,ai,S)}end else for m=1,#I do local ak,n=b(O,"^%s*("..I[m]..")()")if n then local aC;O,aC=a2(c(O,n),z,true)if z then w={C[ak](w[1],aC)}end;break end end end;return O,i(w)end;local function aD(O,z)if z and not z["*nil"]then p=z;z=q(z)end;local a1;O,a1=a0(O)if a1 then if a1=="local"then local aE;O,aE=a0(O)if aE then if aE=="function"then local aF,aw,n,aG=b(O,"^%s*([_%a][_%w]*)%s*%((.-)%)()")O,aG=ac(c(O,n))if z then local s=x(z)z[aF]=function(...)local r=q(z,s)local ar={...}local S=0;local as=false;for at in e(aw,"%s*([^,]+)%s*")do if as then error("error")end;S=S+1;if at=="..."then r["..."]={i(ar,S,select('#',...))}as=true else r[at]=ar[S]end end;return a3(aG,r,"function",nil,aF)end end else local aq={}local S=1;aq[S]=aE;local n=b(O,"^%s*,()")while n do S=S+1;O,aE=a0(c(O,n))aq[S]=aE;n=b(O,"^%s*,()")end;local n=b(O,"^%s*=()")S=0;if n then while n do local aa={a2(c(O,n),z)}O=aa[1]if z then S=S+1;local ab=S;for m=2,h(#aa,2)do if aq[ab]then z[aq[ab]]=aa[m]end;ab=ab+1 end;for m=ab,#aq do z[aq[m]]=nil end end;n=b(O,"^%s*,()")end else if z then for m=1,#aq do z[aq[m]]=nil end end end end else error("error")end elseif a1=="function"then local aF,aw,n,aG=b(O,"^%s*([_%a][_%.:%s%w]*)%s*%(%s*(.-)%)()")O,aG=ac(c(O,n))if z then local t=z;local aH;for n,aI in e(aF,"([^%.%s]+)%s*%.%s*([^%.%s]+)")do t=t[n]aH=aI end;if not aH then aH=b(aF,"[^:%s]+")end;local aJ=b(aF,"^%s*.-%s*:%s*(.*)%s*$")if aJ then t=t[aH]aH=aJ end;local s=x(z)y(t,aH,function(...)local r=q(z,s)if aJ then aw=aw==""and"self"or"self,"..aw end;local ar={...}local S=0;local as=false;for at in e(aw,"%s*([^,]+)%s*")do if as then error("error")end;S=S+1;if at=="..."then r["..."]={i(ar,S,select('#',...))}as=true else r[at]=ar[S]end end;return a3(aG,r,"function",nil,aF)end,z)end elseif a1=="while"then local aA=O;O=a2(O,nil)local aK=c(aA,1,#aA-#O)local n=b(O,"^%s*do()")if n then local af;O,af=ac(c(O,n))if z then while select(2,a2(aK,z))do local r=q(z)local aL={a3(af,r,"breakable")}if aL[1]==A then return i(aL)elseif aL[1]==B then return O end end end else error("do expected")end elseif a1=="for"then local aE,n=b(O,"^%s*([_%a][_%w]*)%s*=()")if aE then local aM;O,aM=a2(c(O,n),z)n=b(O,"^%s*,()")if n then local aN;O,aN=a2(c(O,n),z)local aO;n=b(O,"^%s*,()")if n then O,aO=a2(c(O,n),z)if z and not aO then error("for step must be a number")end end;n=b(O,"^%s*do()")if n then local af;O,af=ac(c(O,n))if z then for m=aM,aN,aO or 1 do local r=q(z)r[aE]=m;local aL={a3(af,r,"breakable")}if aL[1]==A then return i(aL)elseif aL[1]==B then return O end end end else error("error")end else error("error")end else aE,n=b(O,"^%s*(.-)%s+in%s+()")if not aE then error("error")end;local aw={}local S=0;while n do local aa={a2(c(O,n),z)}O=aa[1]S=S+1;local ab=S;for m=2,#aa do aw[ab]=aa[m]ab=ab+1 end;for m=ab,#aw do aw[ab]=nil end;n=b(O,"^%s*,()")end;n=b(O,"^%s*do()")if n then local af;O,af=ac(c(O,n))if z then for a8,ah in Z(aw[1],aw[2],aw[3])do local r=q(z)local S=0;for aP in e(aE,"%s*([^,]+)%s*")do S=S+1;r[aP]=ah[S]end;local aL={a3(af,r,"breakable")}if aL[1]==A then return i(aL)elseif aL[1]==B then return O end end end else error("error")end end elseif a1=="repeat"then local af,aA,aQ;O,af=ac(O,5)aA=O;O=a2(aA,nil)aQ=c(aA,1,#aA-#O)if z then repeat local r=q(z)local aL={a3(af,r,"breakable")}if aL[1]==A then return i(aL)elseif aL[1]==B then return O end until select(2,a2(aQ,z))end elseif a1=="if"then local aQ;O,aQ=a2(O,z)local n=b(O,"^%s*then()")local r;if z then r=q(z)end;if n then local af;O,af=ac(c(O,n),0)if aQ then if z then local aL={a3(af,r,"if")}if aL[1]==A or aL[1]==B then return i(aL)end end;n=b(O,"^elsei?f?()")while n do O=select(1,ac(c(O,n),0))n=b(O,"^elsei?f?()")end;O=c(O,4)else n=b(O,"^elseif()")while n do O,aQ=a2(c(O,n),z)n=b(O,"^%s*then()")if n then O,af=ac(c(O,n),0)if aQ then if z then local aL={a3(af,r,"if")}if aL[1]==A or aL[1]==B then return i(aL)end end;n=b(O,"^elsei?f?()")while n do O=select(1,ac(c(O,n),0))n=b(O,"^elsei?f?()")end;O=c(O,4)break end else error("error")end;n=b(O,"^elseif()")end;if not aQ then n=b(O,"^else()")if n then O,af=ac(c(O,n))if z then local aL={a3(af,r,"if")}if aL[1]==A or aL[1]==B then return i(aL)end end else O=c(O,4)end end end else error("error")end elseif a1=="elseif"then return"",#O+6 elseif a1=="else"then return"",#O+4 elseif a1=="end"then return"",#O+3 elseif a1=="do"then local af;O,af=ac(O)if z then local r=q(z)local aL={a3(af,r,"breakable")}if aL[1]==A then return i(aL)elseif aL[1]==B then return O end end elseif a1=="break"then if z then return B end elseif a1=="return"then local n,S=1,0;local aR={}local a1=select(2,a0(O))if b(O,"^%s*$")or a1 and(a1=="end"or a1=="elseif"or a1=="else"or a1=="until")then if z then return A end else while n do local aa={a2(c(O,n),z)}O=aa[1]S=S+1;local ab=S;for m=2,#aa do aR[ab]=aa[m]ab=ab+1 end;for m=ab,#aR do aR[ab]=nil end;n=b(O,"^%s*,()")end;if z then return A,i(aR)end end elseif a1=="until"then return"",#O+5 else local aq={}local S=0;local aP=a1;local n=1;while n do O=c(O,n)S=S+1;aq[S]={z,aP}while true do n=b(O,"^%s*%[()[^=%]]")if n then if z then aq[S][1]=aq[S][1][aq[S][2]]end;O,aq[S][2]=a2(c(O,n),z)n=b(O,"^%s*%]()")else local ax;ax,n=b(O,"^%s*%.([_%a][_%w]*)()")if n then if z then aq[S][1]=aq[S][1][aq[S][2]]end;aq[S][2]=ax else break end end;O=c(O,n)end;aP,n=b(O,"^%s*,%s*([_%a][_%w]*)()")end;if b(O,"^%s*[:%(\"'{%[]")then local am={}if z then if#aq>1 then error("error")end;am[1]=aq[1][1][aq[1][2]]end;O=a2(O,z,nil,am)else local ak,n=b(O,"^%s*(%S-=)%s*()")S=0;while n do local aa={a2(c(O,n),z)}O=aa[1]if z then S=S+1;local ab=S;for m=2,h(#aa,2)do if aq[ab]then y(aq[ab][1],aq[ab][2],J[ak](aq[ab][1],aq[ab][2],aa[m]),z)end;ab=ab+1 end;for m=ab,#aq do y(aq[m][1],aq[m][2],nil,z)end end;n=b(O,"^%s*,()")end end end else n=b(O,"^%s*%(()")if n then local am={}O,am[1]=a2(c(O,n),z)n=b(O,"^%s*%)()")O=a2(c(O,n),z,nil,am)else error("unexpected character.")end end;return O end;function a3(O,z,aS,aT,aU)aS=aS or"main"if aS=="main"then p=z or _G;p._G=p;O=T(O)z=q(p)end;local aA=O;local aV=function()local aa={}local aW=#O;while not b(O,"^%s*$")do aa={aD(O,z)}O=aa[1]if O==A then if aS=="function"then O=""elseif aS=="main"then error("'return' used outside function")else return i(aa)end end;if O==B then if aS=="function"or aS=="main"then error("'break' used outside loop")else return O end end end;if aT then return aW-(aa[2]or aW)else return i(aa,2)end end;local aX={pcall(aV)}if aX[1]then return i(aX,2)else local aY={err=aX[2]}if aS~="main"then aY.line=select(2,d(aA,"\n",""))-select(2,d(O,"\n",""))+2;if aS=="function"then aY.func=" in function"..(aU and" '"..aU.."'"or"")aY.match="(.*)function%s*"..(aU or"").."%s*%(.*%)%s*"..d(aA,'[%^%$%(%)%%%.%[%]%*%+%-%?]','%%%1')else aY.match=d(aA,'[%^%$%(%)%%%.%[%]%*%+%-%?]','%%%1')end;error(aY)else local aZ=select(2,d(aA,"\n",""))-select(2,d(O,"\n",""))+2;local a_="[LuaYan]:"..aZ..": in main"local b0;while type(aY.err)=="table"do aY=aY.err;if aY.func then b0=select(2,d(b(aA,aY.match),"\n",""))+aY.line;a_="[LuaYan]:"..b0 ..":"..aY.func.."\n"..a_ end end;if b0 then if not aY.func then b0=select(2,d(b(aA,aY.match),"\n",""))+aY.line end else b0=aZ end;a_="[LuaYan]:"..b0 ..b(aY.err,"%d+:(.*)").."\n"..a_;error(a_)end end end;return{readExpression=a2,readLine=aD,readScript=a3,removeComments=T}end luayan = luayan()
  19.  
  20. local block = require('string-to-boolean').parse({"eventFileLoaded", "eventPlayerDataLoaded"})
  21. local events = {"eventChatCommand ","eventChatMessage","eventEmotePlayed","eventFileLoaded","eventFileSaved","eventKeyboard","eventMouse","eventLoop","eventNewGame","eventNewPlayer","eventPlayerDataLoaded","eventPlayerDied","eventPlayerGetCheese","eventPlayerLeft","eventPlayerVampire","eventPlayerWon","eventPlayerRespawn","eventPlayerMeep","eventPopupAnswer","eventSummoningStart","eventSummoningCancel","eventSummoningEnd","eventTextAreaCallback","eventColorPicked"}
  22. local minigameMap = false;
  23. local loaded = false;
  24.  
  25. local split = function(t, s)
  26.     local a={}
  27.     for i in string.gmatch(t, "[^" .. (s or "%s") .. "]+") do
  28.         a[#a + 1] = i
  29.     end
  30.     return a
  31. end
  32.  
  33. local resetEvents = function(g)
  34.     for i, v in next, events do
  35.         old_G[v] = function() end
  36.         if not g then
  37.             if block[v] then
  38.                 _G[v] = function(...) end
  39.             else
  40.                 _G[v] = function(...) old_G[v](...) end
  41.             end
  42.         end
  43.     end
  44. end
  45.  
  46. resetEvents()
  47.  
  48. eventChatCommand = function(name, cmd)
  49.     local arg = split(cmd, ' ')
  50.     if arg[1] == 'map' and not minigameMap and arg[2] and arg[2]:find('^@') and tonumber(tostring(arg[2]:gsub('@', ''))) then
  51.         minigameMap = arg[2]
  52.         tfm.exec.newGame(minigameMap)
  53.     end
  54. end
  55.  
  56. eventNewGame = function()
  57.     if '@'..tfm.get.room.xmlMapInfo.mapCode == minigameMap and not loaded then
  58.         loaded = true
  59.         local xml = tfm.get.room.xmlMapInfo.xml:match('<lua script="(.+)"')
  60.         if xml then
  61.             local sucesso, err = pcall(function()luayan.readScript(xml:gsub('<','&lt;'):gsub('(..)', function(b) return string.char('0x'..b) end), old_G)end)
  62.             if not sucesso then
  63.                 tfm.exec.chatMessage('<B><R>[ERROR]</R></B> '..err);
  64.             end
  65.         else
  66.             tfm.exec.chatMessage('<B><R>[ERROR]</R></B> Xml inválida');
  67.         end
  68.     elseif loaded then
  69.         resetEvents(true)
  70.         loaded = false
  71.         minigameMap = false
  72.     end
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement