Advertisement
Bolodefchoco_LUAXML

[Game] Agar.io

Apr 8th, 2017
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.64 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 08/04/2017
  3. --Last update: 08/04/2017
  4.  
  5. tfm.exec.disableAutoShaman()
  6. tfm.exec.disableAutoNewGame()
  7.  
  8. math.inSquare = function(x1,y1,r1,x2,y2,r2)
  9.     return (x1 + r1 > x2 - r2 and x1 - r1 < x2 + r2) and (y1 + r1 > y2 - r2 and y1 - r1 < y2 + r2)
  10. end
  11.  
  12. info = {}
  13. eventNewPlayer = function(n)
  14.     if not info[n] then
  15.         info[n] = {
  16.             n = n,
  17.             id = tfm.get.room.playerList[n].id,
  18.             isDead = {false,0},
  19.             capture = 0,
  20.             size = 10,
  21.             speed = 5,
  22.             boost = {0,0,0}, -- speed, end, is boosting
  23.             color = math.random(0xFFFFFF),
  24.             coord = {math.random(800),math.random(400)},
  25.             dir = {0,0},
  26.         }
  27.     end
  28.     for k,v in next,{0,1,2,3,32,string.byte("POB",1,3)} do
  29.         system.bindKeyboard(n,v,true,true)
  30.         system.bindKeyboard(n,v,false,true)
  31.     end
  32. end
  33. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  34.  
  35. eventNewGame = function()
  36.     table.foreach(tfm.get.room.playerList,tfm.exec.killPlayer)
  37. end
  38.  
  39. eventLoop = function(currentTime)
  40.     if currentTime / 1000 > 3 then
  41.         for k,v in next,info do
  42.             if not v.isDead[1] then
  43.                 v.coord[1] = v.coord[1] + v.dir[1]
  44.                 v.coord[2] = v.coord[2] + v.dir[2]
  45.                
  46.                 if v.coord[1] < 1 then
  47.                     v.coord[1] = 800
  48.                 elseif v.coord[1] > 800 then
  49.                     v.coord[1] = 1
  50.                 end
  51.                
  52.                 if v.coord[2] < 1 then
  53.                     v.coord[2] = 400
  54.                 elseif v.coord[2] > 400 then
  55.                     v.coord[2] = 1
  56.                 end
  57.  
  58.                 if v.boost[3] == 1 then
  59.                     if v.boost[2] > 0 then
  60.                         v.boost[2] = v.boost[2] - .5
  61.                     else
  62.                         v.boost[2] = 0
  63.                         v.boost[3] = 0
  64.                         v.speed = v.boost[1]
  65.                     end
  66.                 else
  67.                     if v.boost[2] < 4.5 then
  68.                         v.boost[2] = v.boost[2] + .05
  69.                     end
  70.                 end
  71.  
  72.                 ui.addTextArea(v.id or 1000,"",nil,v.coord[1] or 0,v.coord[2] or 0,v.size or 10,v.size or 10,v.color or 1,v.color or 1,.5,true)
  73.                 ui.addTextArea(-v.id,"<font size='8' color='#E6FF00'>" .. v.n,nil,v.coord[1] - 10 - #v.n,v.coord[2] - (v.size/2) - 15,nil,nil,1,1,0,true)
  74.                 ui.addTextArea(0,string.format("X: %s\nY: %s\nSize: %sx%s\nSpeed: %s\nBoost: %s",v.coord[1],v.coord[2],v.size,v.size,v.speed,v.boost[2]),v.n,0,30,120,100,1,1,0,true)
  75.             else
  76.                 if os.time() > v.isDead[2] then
  77.                     v.isDead = {false,0}
  78.                     v.coord = {math.random(800),math.random(400)}
  79.                 end
  80.             end
  81.         end
  82.     end
  83. end
  84.  
  85. eventKeyboard = function(n,k,d)
  86.     if k == 32 then
  87.         if os.time() > info[n].capture then
  88.             info[n].capture = os.time() + 5000
  89.            
  90.             for k,v in next,info do
  91.                 if n ~= v.n then
  92.                     if math.inSquare(v.coord[1],v.coord[2],v.size,info[n].coord[1],info[n].coord[2],info[n].size) then
  93.                         info[n].size = info[n].size + (10/100) * v.size
  94.                         info[n].speed = info[n].speed + (15/100) * v.speed
  95.                         ui.removeTextArea(v.id,nil)
  96.                         ui.removeTextArea(-v.id,nil)
  97.                         ui.removeTextArea(0,v.n)
  98.                        
  99.                         v.isDead = {true,os.time() + 10000}
  100.                         v.size = 10
  101.                         v.speed = 5
  102.                        
  103.                         info[n].capture = 0
  104.                         break
  105.                     end
  106.                 end
  107.             end
  108.         end
  109.     elseif k == string.byte("B") then
  110.         if info[n].boost[2] > .5 then
  111.             info[n].boost[3] = d and 1 or 0
  112.             if d then
  113.                 info[n].boost[1] = info[n].speed
  114.                 info[n].speed = info[n].speed * 2.5
  115.             else
  116.                 info[n].speed = info[n].boost[1]
  117.             end
  118.         end
  119.     elseif k == string.byte("P") then
  120.        
  121.     elseif k == string.byte("O") then
  122.         ui.showColorPicker(0,n,info[n].color,"Square")
  123.     else
  124.         if k == 0 then
  125.             info[n].dir = {-info[n].speed,0}
  126.         elseif k == 2 then
  127.             info[n].dir = {info[n].speed,0}
  128.         elseif k == 1 then
  129.             info[n].dir = {0,-info[n].speed}
  130.         elseif k == 3 then
  131.             info[n].dir = {0,info[n].speed}
  132.         end
  133.     end
  134. end
  135.  
  136. eventColorPicked = function(i,n,c)
  137.     info[n].color = c
  138. end
  139.  
  140. tfm.exec.newGame('<C><P /><Z><S /><D /><O /></Z></C>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement