Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local this = {}
- room = function()
- local this = {}
- __init__=function()
- addTimer(this.eventLoop, 10, 0)
- this.timer = os.time();
- this.cano={}
- this.canos=0
- this.canex=0
- this.move=false
- this.nuvem={
- y=math.random(30,250),
- x=850,
- w=math.random(50,100),
- h=math.random(0,30),
- }
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoTimeLeft(true)
- tfm.exec.disableAfkDeath(true)
- tfm.exec.disableAutoScore(true)
- tfm.exec.disablePhysicalConsumables(true)
- tfm.exec.disableMortCommand(true)
- this.roundTime = 99999
- this.mapXML = '<C><P aie="5" Ca="" G="0,10" /><Z><S><S H="400" L="800" o="1c9cdd" X="400" c="4" Y="200" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="17" o="1c9cdd" H="400" X="-9" Y="199" T="12" P="0,0,0,0,0,0,0,0" /><S P="0,0,0,0,0,0,0,0" L="17" o="1c9cdd" X="400" Y="200" T="12" H="400" /><S L="800" H="10" X="400" Y="-4" T="3" P="0,0,0,0,0,0,0,0" /><S H="10" L="150" o="0B3707" X="79" c="4" Y="456" T="13" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="150" o="0B3707" X="214" c="4" Y="463" T="13" H="10" /><S P="0,0,0.3,0.2,0,0,0,0" L="150" o="0B3707" X="358" c="4" Y="461" T="13" H="10" /><S H="10" L="150" o="0B3707" X="506" c="4" Y="460" T="13" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="150" o="0B3707" X="668" c="4" Y="460" T="13" H="10" /><S H="10" L="150" o="0B3707" X="825" c="4" Y="457" T="13" P="0,0,0.3,0.2,0,0,0,0" /><S H="17" L="668" o="0B3707" X="444" c="4" Y="333" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="150" o="0B3707" X="-49" c="4" Y="443" T="13" H="10" /></S><D><DS Y="133" X="134" /></D><O /></Z></C>'
- this.newMap()
- end
- this.eventLoop=function()
- this.updateCanes()
- end
- this.newMap=function()
- tfm.exec.newGame(this.mapXML)
- tfm.exec.setGameTime(this.roundTime)
- this.cano={}
- this.canos=0
- this.canex=0
- for all in pairs(tfm.get.room.playerList) do
- tfm.exec.setPlayerScore(all,0,false)
- end
- end
- this.updateMove=function(boolean)
- this.move=boolean
- end
- this.updateCanes=function()
- if this.move then
- this.nuvem.x=this.nuvem.x-5
- tfm.exec.addPhysicObject(-1,this.nuvem.x,this.nuvem.y,{type=12,width=this.nuvem.w,height=this.nuvem.h,friction=81,restitution=99,color="0xFFFFFF",miceCollision=false,foreground=false})
- if this.nuvem.x <= (0-(this.nuvem.h+20)) then
- this.nuvem.y=math.random(30,250)
- this.nuvem.x=900
- this.w=math.random(50,100)
- this.h=math.random(10,30)
- end
- if this.timer < os.time()-3000 then
- this.canos=this.canos+1
- local canose={
- id=canos,
- x=900,
- alt=math.random(80,220),
- }
- table.insert(this.cano,canose)
- this.timer = os.time();
- end
- local insert=nil
- for i,v in pairs(this.cano) do
- v.x=v.x-35
- tfm.exec.addPhysicObject(i,v.x,v.alt/2,{type=12,width=50,height=v.alt,friction=81,restitution=99,color="0x17720F"})
- tfm.exec.addPhysicObject(i+10,v.x,v.alt-15,{type=12,width=72,height=40,friction=81,restitution=99,color="0x17720F"})
- tfm.exec.addPhysicObject(i+20,v.x,((400-v.alt)/2)+(v.alt+145),{type=12,width=50,height=400-v.alt,friction=81,restitution=99,color="0x17720F"})
- tfm.exec.addPhysicObject(i+30,v.x,v.alt+145,{type=12,width=72,height=40,friction=81,restitution=99,color="0x17720F"})
- if v.x <= -50 then
- insert=i+this.canex
- end
- for j,p in pairs(tfm.get.room.playerList) do
- if not p.isDead then
- if v.x == 115 then
- local px=tfm.get.room.playerList[j].x
- local py=tfm.get.room.playerList[j].y
- if py < v.alt+15 or py > v.alt+145 then
- tfm.exec.killPlayer(j)
- else
- tfm.exec.setPlayerScore(j,1,true)
- ui.addTextArea(1,"<font size='40' color='#FFFFFF'>"..tfm.get.room.playerList[j].score+1,j,400,30,0,0,1,1,0,true)
- end
- end
- end
- end
- end
- if insert~=nil then
- tfm.exec.removeObject(insert)
- tfm.exec.removeObject(insert+10)
- tfm.exec.removeObject(insert+20)
- tfm.exec.removeObject(insert+30)
- table.remove(this.cano, 1)
- this.canex=this.canex+1
- end
- end
- end
- return {main=__init__,newMap=this.newMap,updateMove=this.updateMove}
- end
- bird = function()
- local this = {}
- __init__ = function()
- this.birds = {}
- addTimer(this.eventLoop, 10, 0)
- end
- this.eventLoop=function()
- for _,bird in pairs(this.birds) do
- if not bird.isDead then
- ui.addTextArea(-1,"<font size='40' color='#FFFFFF'>"..tfm.get.room.playerList[bird.name].score,bird.name,400,30,0,0,1,1,0,true)
- if bird.fly then this.flying(bird.name) end
- end
- end
- end
- this.flying=function(name)
- tfm.exec.movePlayer(name,0,0,false,0,-50,true)
- end
- this.sendPlayUI=function(name)
- ui.addTextArea(0,"",name,-10,-20,850,450,0x1c9cdd,0x1c9cdd,1,true)
- ui.addTextArea(1,"",name,8,293,200,100,0x1091cc,0x1091cc,1,true)
- ui.addTextArea(2,"<a href='event:play'><font color='#ededed' face='Arial Black' size='14'>Play",name,8,376,50,80,0x1091cc,0x1091cc,1,true)
- end
- this.addClient=function(name)
- this.birds[name]={
- name=name,
- isDead=true,
- fly=false
- }
- tfm.exec.killPlayer(name)
- this.sendPlayUI(name)
- system.bindKeyboard(name,32,true,true)
- system.bindKeyboard(name,32,false,true)
- end
- this.status=function(isDead,fly,name)
- if not isDead then this.birds[name].fly=fly end
- if isDead then
- ui.removeTextArea(-1,name)
- this.sendPlayUI(name)
- else
- if this.birds[name].isDead then
- tfm.exec.respawnPlayer(name)
- for i=0,2 do ui.removeTextArea(i,name) end
- end
- end
- this.birds[name].isDead=isDead
- end
- return {main=__init__,newPlayer=this.addClient,status=this.status}
- end
- local a={}function addTimer(b,c,d,e,...)local f=#a+1;a[f]={callback=b,label=e,arguments={...},time=c,currentTime=0,currentLoop=0,loops=d or 1,isComplete=false}return f end;function removeTimer(f)if a[f]then a[f]=0;return true end;return false end;function clearTimers()a={}end;function eventLoop(g,h)local i={}for f=1,#a do local j=a[f]if type(j)=='table'then if not j.isComplete then j.currentTime=j.currentTime+500;if j.currentTime>=j.time then j.currentTime=0;j.currentLoop=j.currentLoop+1;if j.loops>0 then if j.currentLoop>=j.loops then j.isComplete=true end end;if type(j.callback)=='function'then j.callback(j.currentLoop,table.unpack(j.arguments))end end end;if j.isComplete then if type(eventTimerComplete)=='function'then eventTimerComplete(f,j.label)end;i[#i+1]=f end end end;for k=1,#i do removeTimer(i[k])end
- -- EventLoop aqui
- end
- split=function(t,s)
- local a={};for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do table.insert(a,i);end return a;
- end
- function eventPlayerDied(name)
- this.bird.status(true,false,name)
- end
- function eventTextAreaCallback(id,name,link)
- call = split(link,' ')
- if call[1] == 'play' then
- this.bird.status(false,false,name)
- end
- end
- function eventKeyboard(name,key,down,x,y)
- if key == 32 then
- this.bird.status(tfm.get.room.playerList[name].isDead,down,name)
- end
- end
- function eventNewGame()
- this.room.updateMove(true)
- end
- this.bird = bird()
- this.bird.main()
- this.room = room()
- this.room.main()
- function eventNewPlayer() end
- eventNewPlayer=this.bird.newPlayer
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
- this.room.newMap()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement