Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tfm.exec.disableAutoShaman()
- tfm.exec.disableAutoNewGame()
- tfm.exec.disableAutoScore()
- tfm.exec.disableAfkDeath()
- balls={}
- textarea=ui.addTextArea
- function ui.newAddTxtA(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss)
- textarea(6969+id,"",targetPlayer,x,y+1,width,height,0x000001,0x000001,backgroundAlpha,emboss)
- textarea(7979+id,"",targetPlayer,x,y-1,width,height,0x6A8FA2,0x6A8FA2,backgroundAlpha,emboss)
- textarea(id,text,targetPlayer,x,y,width,height,backgroundColor,borderColor,backgroundAlpha,emboss)
- end
- math.inSquare = function(x1,y1,r1,x2,y2,r2)
- return (x1 + r1 > x2 - r2 and x1 - r1 < x2 + r2) and (y1 + r1 > y2 - r2 and y1 - r1 < y2 + r2)
- end
- function showPlay(id)
- local n = ''
- for i,v in pairs(tfm.get.room.playerList) do if v.id == id then n = i break end end
- ui.addTextArea(1,'',n,-300,-200,9999,9999,0x0001,0x0001,1,true)
- ui.removeTextArea(0,n)
- ui.newAddTxtA(2,"",n,350,200,200,100,0x142730,0x142730,nil,true)
- ui.addTextArea(3,"<p align='center'><font size='50' color='#6A8FA2' face='Berlin Sans FB'><B>Agar.io</B></font></p>",n,302,102-0.5,300,150,0,0,0,true)
- ui.addTextArea(4,"<p align='center'><font size='50' color='#F8F8FF' face='Berlin Sans FB'><B>Agar.io</B></font></p>",n,300,100,300,150,0,0,0,true)
- ui.newAddTxtA(5,"<p align='center'><font size='13' color='#F8F8FF'><a href='event:play'>Play game</a></font></p>",n,352,202,100,20,0x324650,0x324650,nil,true)
- ui.newAddTxtA(6,"<p align='center'><font size='10' color='#F8F8FF'><a href='event:editName'>"..data[n].n.."</a></font></p>",n,352,235,100,20,0x324650,0x324650,nil,true)
- ui.newAddTxtA(7,"<p align='center'><font size='10' color='#F8F8FF'>"..data[n].points.."</font></p>",n,352,270,100,20,0x324650,0x324650,nil,true)
- ui.newAddTxtA(8,"<p align='center'><font size='10' color='"..data[n].color2.."'><a href='event:skinColor'>Color Skin</a></font></p>",n,465,202,80,20,0x324650,0x324650,nil,true)
- end
- function positionTest()
- local ballsToRemove={}
- for n in pairs(tfm.get.room.playerList) do
- if not data[n].isDead[1] then
- if os.time() > data[n].capture then
- data[n].capture = os.time() + 5000
- for k,v in pairs(balls) do
- if math.inSquare(v.x,v.y,v.size,data[n].coord[1],data[n].coord[2],(data[n].size/(data[n].divide/2)) + 4) then
- data[n].size = data[n].size + v.size/2
- data[n].points = data[n].points + v.size/2 + math.random(-5.0,5.0)
- tfm.exec.setPlayerScore(n,math.floor(data[n].points),false)
- data[n].speed = data[n].speed + (15/100) * 10
- local d = math.random(1,4)
- if d == 2 or v == d then
- data[n].divide=data[n].divide+1
- end
- ui.removeTextArea(v.id,nil)
- table.insert(ballsToRemove,k)
- end
- end
- for k,v in next,data do
- if n ~= getName(v.id) and not data[n].isDead[1] and not v.isDead[1] then
- if data[n].size > data[getName(v.id)].size and math.inSquare(v.coord[1],v.coord[2],v.size,data[n].coord[1],data[n].coord[2],(data[n].size/2) + 4) then
- data[n].size = data[n].size + v.size/2
- data[n].points = data[n].points + v.size/2 + math.random(-5.0,5.0)
- tfm.exec.setPlayerScore(n,math.floor(data[n].points),false)
- data[n].speed = data[n].speed + (15/100) * v.speed
- local d = math.random(1,4)
- if d == 2 or d == 4 then
- data[n].divide=data[n].divide+1
- end
- ui.removeTextArea(v.id,nil)
- ui.removeTextArea(-v.id,nil)
- ui.removeTextArea(0,v.n)
- showPlay(v.id)
- v.isDead = {true,os.time() + 10000}
- v.size = 10
- v.speed = 5
- data[n].capture = 0
- break
- end
- end
- end
- end
- end
- end
- for i,v in pairs(ballsToRemove) do
- table.remove(balls,v)
- end
- ballsToRemove={}
- end
- data = {}
- eventNewPlayer = function(n)
- if not data[n] then
- data[n] = {
- n = n,
- id = tfm.get.room.playerList[n].id,
- isDead = {true,0},
- capture = 0,
- size = 10,
- speed = 5,
- boost = {0,0,0}, -- speed, end, is boosting
- color = 0xFFFFFF,
- color2 = '#FFFFFF',
- coord = {math.random(10,1600),math.random(20,380)},
- dir = {0,0},
- divide=2,
- timeToMove=0,
- points=0,
- }
- end
- for k,v in next,{37,38,39,40,65,68,83,87,32,string.byte("POB",1,3)} do
- system.bindKeyboard(n,v,true,true)
- system.bindKeyboard(n,v,false,true)
- end
- ui.addTextArea(1,'',n,-300,-200,9999,9999,0x0001,0x0001,1,false)
- showPlay(data[n].id)
- tfm.exec.setPlayerScore(n,data[n].points,false)
- end
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
- eventNewGame = function()
- --table.foreach(tfm.get.room.playerList,tfm.exec.killPlayer)
- tfm.exec.setGameTime(9999999)
- end
- spawnCollectiveBalls=function()
- if #balls < 30 then
- local id=-#balls
- local x=math.random(10,1590)
- local y=math.random(20,370)
- local size=math.random(5,20)
- local color=math.random(0,0xFFFFFF)
- table.insert(balls,{id=id,x=x,y=y,size=size,color=color})
- ui.addTextArea(id,"",nil,x,y,size/2,size/2,color,color,1,false)
- end
- end
- function eventPlayerDied(name)
- tfm.exec.respawnPlayer(name)
- end
- eventLoop = function(currentTime)
- spawnCollectiveBalls()
- if currentTime / 1000 > 3 then
- UpdateAll()
- end
- end
- function UpdateAll()
- for k,v in next,data do
- if not v.isDead[1] then
- v.coord[1] = v.coord[1] + v.dir[1]
- v.coord[2] = v.coord[2] + v.dir[2]
- if data[getName(v.id)] and data[getName(v.id)].timeToMove < os.time()-800 then
- local n = getName(v.id)
- tfm.exec.movePlayer(n,data[n].coord[1],0,false)
- data[n].timeToMove=os.time();
- end
- positionTest()
- if v.coord[1] < 1 then
- v.coord[1] = 1600
- elseif v.coord[1] > 1600 then
- v.coord[1] = 1
- end
- if v.coord[2] < 1 then
- v.coord[2] = 400
- elseif v.coord[2] > 400 then
- v.coord = 10
- end
- if v.boost[3] == 1 then
- if v.boost[2] > 0 then
- v.boost[2] = v.boost[2] - .5
- else
- v.boost[2] = 0
- v.boost[3] = 0
- v.speed = v.boost[1]
- end
- else
- if v.boost[2] < 4.5 then
- v.boost[2] = v.boost[2] + .05
- end
- end
- n=getName(v.id)
- ui.addTextArea(v.id,"",nil,v.coord[1],v.coord[2],v.size/v.divide,v.size/v.divide,v.color,v.color,0.5,false)
- ui.addTextArea(-v.id,"<font size='8' color='#E6FF00'>" .. v.n,nil,v.coord[1] - 10 - #v.n,v.coord[2] - (v.size/v.divide) - 15,nil,nil,1,1,0,false)
- ui.addTextArea(0,string.format("X: %s\nY: %s\nMass: %s\nSpeed: %s\nBoost: %s\nPoints: %s",v.coord[1],v.coord[2],math.floor(v.size),v.speed,v.boost[2],v.points),n,0,30,120,100,1,1,0,true)
- else
- n=getName(v.id)
- for k,d in next,data do
- ui.removeTextArea(d.id,n)
- ui.removeTextArea(-d.id,n)
- end
- tfm.exec.setPlayerScore(n,-1,false)
- end
- end
- end
- function eventPopupAnswer(id,n,answer)
- if id == 0 and #answer ~= 0 then
- local n2 = ''
- for i=1,#answer do
- if i <= 12 then
- n2=n2..answer:sub(i,i)
- end
- end
- data[n].n=n2
- showPlay(data[n].id)
- end
- end
- function eventTextAreaCallback(id,n,link)
- if link == "play" then
- for i=2,8 do
- ui.removeTextArea(i,n)ui.removeTextArea(6969+i,n)ui.removeTextArea(7979+i,n)
- end
- ui.addTextArea(1,'',n,-300,-200,9999,9999,0x0001,0x0001,1,false)
- for i,v in pairs(balls) do
- v.color=math.random(0,0xFFFFFF)
- ui.addTextArea(v.id,"",n,v.x,v.y,v.size/2,v.size/2,v.color,v.color,1,false)
- end
- data[n].isDead = {false,0}
- data[n].coord = {math.random(10,790),math.random(40,380)}
- data[n].size = 10
- data[n].points = 0
- tfm.exec.movePlayer(n,data[n].coord[1],0,false)
- tfm.exec.setPlayerScore(n,data[n].points,false)
- end
- if link == "editName" then
- v=data[n]
- ui.addPopup(0,2,'<p align="center"><B>Troca de Nome</B></p>Seu nome atual é <B>'..v.n..'</B>.',n,352,202,196,true)
- end
- if link == "skinColor" then
- ui.showColorPicker(0,n,data[n].color,"Color Skin")
- end
- end
- getName=function(id)
- local n = nil
- for i,d in pairs(tfm.get.room.playerList) do if d.id == id then n = i break end end
- return n
- end
- eventKeyboard = function(n,k,d)
- if k == string.byte("B") then
- if data[n].boost[2] > .5 then
- data[n].boost[3] = d and 1 or 0
- if d then
- data[n].size=data[n].size-0.01
- data[n].boost[1] = data[n].speed
- data[n].speed = data[n].speed * 2.5
- else
- data[n].speed = data[n].boost[1]
- end
- end
- elseif k == string.byte("P") then
- elseif k == string.byte("O") then
- --ui.showColorPicker(0,n,data[n].color,"Square")
- else
- if k == 37 then
- data[n].dir = {-data[n].speed,0}
- elseif k == 39 then
- data[n].dir = {data[n].speed,0}
- elseif k == 38 then
- data[n].dir = {0,-data[n].speed}
- elseif k == 40 then
- data[n].dir = {0,data[n].speed}
- end
- end
- end
- eventColorPicked = function(i,n,c)
- if not c ~= "-1" and c ~= -1 and c ~= "0x0" then
- data[n].color = '0x'..string.format("%x", c)
- data[n].color2='#'..string.format("%x", c)
- showPlay(data[n].id)
- end
- end
- tfm.exec.newGame('<C><P L="1600" /><Z><S><S L="3000" o="1" H="10" X="1501" Y="396" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,,0.2,090,0,0,0" L="3000" o="1" X="0" Y="256" T="12" H="10" /><S L="3000" o="1" X="1600" H="10" Y="207" T="12" P="0,0,,0.2,090,0,0,0" /></S><D /><O /></Z></C>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement