Advertisement
Dudugz-Contistente

Untitled

Oct 25th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.28 KB | None | 0 0
  1. local this = {}
  2.  
  3. room = function()
  4. local this = {}
  5.  
  6. __init__=function()
  7. addTimer(this.eventLoop, 10, 0)
  8.  
  9. this.timer = os.time();
  10. this.cano={}
  11. this.canos=0
  12. this.canex=0
  13. this.move=false
  14. this.nuvem={
  15. y=math.random(30,250),
  16. x=850,
  17. w=math.random(50,100),
  18. h=math.random(0,30),
  19. }
  20.  
  21. tfm.exec.disableAutoNewGame(true)
  22. tfm.exec.disableAutoShaman(true)
  23. tfm.exec.disableAutoTimeLeft(true)
  24. tfm.exec.disableAfkDeath(true)
  25. tfm.exec.disableAutoScore(true)
  26. tfm.exec.disablePhysicalConsumables(true)
  27. tfm.exec.disableMortCommand(true)
  28.  
  29. this.roundTime = 99999
  30. 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>'
  31.  
  32. this.newMap()
  33. end
  34.  
  35. this.eventLoop=function()
  36. this.updateCanes()
  37. end
  38.  
  39. this.newMap=function()
  40. tfm.exec.newGame(this.mapXML)
  41. tfm.exec.setGameTime(this.roundTime)
  42.  
  43. this.cano={}
  44. this.canos=0
  45. this.canex=0
  46. for all in pairs(tfm.get.room.playerList) do
  47. tfm.exec.setPlayerScore(all,0,false)
  48. end
  49. end
  50.  
  51. this.updateMove=function(boolean)
  52. this.move=boolean
  53. end
  54.  
  55. this.updateCanes=function()
  56. if this.move then
  57. this.nuvem.x=this.nuvem.x-5
  58. 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})
  59. if this.nuvem.x <= (0-(this.nuvem.h+20)) then
  60. this.nuvem.y=math.random(30,250)
  61. this.nuvem.x=900
  62. this.w=math.random(50,100)
  63. this.h=math.random(10,30)
  64. end
  65. if this.timer < os.time()-3000 then
  66. this.canos=this.canos+1
  67. local canose={
  68. id=canos,
  69. x=900,
  70. alt=math.random(80,220),
  71. }
  72. table.insert(this.cano,canose)
  73. this.timer = os.time();
  74. end
  75. local insert=nil
  76. for i,v in pairs(this.cano) do
  77. v.x=v.x-35
  78. tfm.exec.addPhysicObject(i,v.x,v.alt/2,{type=12,width=50,height=v.alt,friction=81,restitution=99,color="0x17720F"})
  79. tfm.exec.addPhysicObject(i+10,v.x,v.alt-15,{type=12,width=72,height=40,friction=81,restitution=99,color="0x17720F"})
  80. 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"})
  81. tfm.exec.addPhysicObject(i+30,v.x,v.alt+145,{type=12,width=72,height=40,friction=81,restitution=99,color="0x17720F"})
  82. if v.x <= -50 then
  83. insert=i+this.canex
  84. end
  85. for j,p in pairs(tfm.get.room.playerList) do
  86. if not p.isDead then
  87. if v.x == 115 then
  88. local px=tfm.get.room.playerList[j].x
  89. local py=tfm.get.room.playerList[j].y
  90. if py < v.alt+15 or py > v.alt+145 then
  91. tfm.exec.killPlayer(j)
  92. else
  93. tfm.exec.setPlayerScore(j,1,true)
  94. ui.addTextArea(1,"<font size='40' color='#FFFFFF'>"..tfm.get.room.playerList[j].score+1,j,400,30,0,0,1,1,0,true)
  95. end
  96. end
  97. end
  98. end
  99. end
  100. if insert~=nil then
  101. tfm.exec.removeObject(insert)
  102. tfm.exec.removeObject(insert+10)
  103. tfm.exec.removeObject(insert+20)
  104. tfm.exec.removeObject(insert+30)
  105. table.remove(this.cano, 1)
  106. this.canex=this.canex+1
  107. end
  108. end
  109. end
  110.  
  111. return {main=__init__,newMap=this.newMap,updateMove=this.updateMove}
  112. end
  113.  
  114. bird = function()
  115. local this = {}
  116.  
  117. __init__ = function()
  118. this.birds = {}
  119.  
  120. addTimer(this.eventLoop, 10, 0)
  121. end
  122.  
  123. this.eventLoop=function()
  124. for _,bird in pairs(this.birds) do
  125. if not bird.isDead then
  126. 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)
  127. if bird.fly then this.flying(bird.name) end
  128. end
  129. end
  130. end
  131.  
  132. this.flying=function(name)
  133. tfm.exec.movePlayer(name,0,0,false,0,-50,true)
  134. end
  135.  
  136. this.sendPlayUI=function(name)
  137. ui.addTextArea(0,"",name,-10,-20,850,450,0x1c9cdd,0x1c9cdd,1,true)
  138. ui.addTextArea(1,"",name,8,293,200,100,0x1091cc,0x1091cc,1,true)
  139. 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)
  140. end
  141.  
  142. this.addClient=function(name)
  143. this.birds[name]={
  144. name=name,
  145. isDead=true,
  146. fly=false
  147. }
  148.  
  149. tfm.exec.killPlayer(name)
  150. this.sendPlayUI(name)
  151.  
  152. system.bindKeyboard(name,32,true,true)
  153. system.bindKeyboard(name,32,false,true)
  154. end
  155.  
  156. this.status=function(isDead,fly,name)
  157. if not isDead then this.birds[name].fly=fly end
  158.  
  159. if isDead then
  160. ui.removeTextArea(-1,name)
  161. this.sendPlayUI(name)
  162. else
  163. if this.birds[name].isDead then
  164. tfm.exec.respawnPlayer(name)
  165.  
  166.  
  167. for i=0,2 do ui.removeTextArea(i,name) end
  168. end
  169. end
  170.  
  171. this.birds[name].isDead=isDead
  172. end
  173.  
  174. return {main=__init__,newPlayer=this.addClient,status=this.status}
  175. end
  176.  
  177. 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
  178. -- EventLoop aqui
  179.  
  180. end
  181.  
  182. split=function(t,s)
  183. local a={};for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do table.insert(a,i);end return a;
  184. end
  185.  
  186. function eventPlayerDied(name)
  187. this.bird.status(true,false,name)
  188. end
  189.  
  190. function eventTextAreaCallback(id,name,link)
  191. call = split(link,' ')
  192.  
  193. if call[1] == 'play' then
  194. this.bird.status(false,false,name)
  195. end
  196. end
  197.  
  198. function eventKeyboard(name,key,down,x,y)
  199. if key == 32 then
  200. this.bird.status(tfm.get.room.playerList[name].isDead,down,name)
  201. end
  202. end
  203.  
  204. function eventNewGame()
  205. this.room.updateMove(true)
  206. end
  207.  
  208. this.bird = bird()
  209. this.bird.main()
  210.  
  211. this.room = room()
  212. this.room.main()
  213.  
  214. function eventNewPlayer() end
  215.  
  216. eventNewPlayer=this.bird.newPlayer
  217.  
  218. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  219. this.room.newMap()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement