Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- admin = "Abdeltif"
- default = {width = 50, height = 50}
- prot = {}
- prot[0] = {
- type = 0,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 0.3,
- restitution = 0.2,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[1] = {
- type = 1,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 0,
- restitution = 0.2,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[2] = {
- type = 2,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 0,
- restitution = 1.2,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[3] = {
- type = 3,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 0,
- restitution = 20,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[4] = {
- type = 4,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 20,
- restitution = 0.2,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[5] = {
- type = 5,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 0.3,
- restitution = 0.2,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[6] = {
- type = 6,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 0.3,
- restitution = 0.2,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[7] = {
- type = 7,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 0.1,
- restitution = 0.2,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[8] = {
- type = 8,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 0.3,
- restitution = 0.2,
- angle = 0,
- miceCollision = false,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[9] = {
- type = 9,
- width = default.width,
- height = default.height,
- foreground = false,
- }
- prot[10] = {
- type = 10,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 0.3,
- restitution = 0,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[11] = {
- type = 11,
- width = default.width,
- height = default.height,
- foreground = false,
- friction = 0.05,
- restitution = 0.1,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[12] = {
- type = 12,
- width = default.width,
- height = default.height,
- color = 0x5F58F2,
- foreground = false,
- friction = 0.3,
- restitution = 0.2,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- prot[13] = {
- type = 13,
- width = default.width,
- color = 0x0FF0F0,
- foreground = false,
- friction = 0.3,
- restitution = 0.2,
- angle = 0,
- miceCollision = true,
- groundCollision = true,
- dynamic = false,
- fixedRotation = false,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0,
- }
- id = 0
- gnum = 1
- players = {}
- sparkles = {}
- roles = {
- "many",
- "whole"
- }
- grounds = {
- wood = 0,
- ice = 1,
- trampoline = 2,
- lava = 3,
- chocolate = 4,
- earth = 5,
- grass = 6,
- sand = 7,
- cloud = 8,
- water = 9,
- stone = 10,
- snow = 11,
- rectangle = 12,
- circle = 13,
- }
- function eventNewPlayer(name)
- system.bindMouse(name, true)
- system.bindKeyboard(name, 17 , false, true)
- players[name] = {mode = "whole", ids = {}, gtype = 1, color = 0xF45F63, hold = false, height = 10}
- end
- function eventKeyboard(name, key, down, x, y)
- if key == 17 and down then
- players[name].hold = true
- system.bindKeyboard(name, 17, false, true)
- elseif key==17 and not down then
- players[name].hold = false
- system.bindKeyboard(name, 17, true, true)
- end
- end
- function eventPlayerLeft(name)
- for k,v in pairs(players[name].ids) do
- tfm.exec.removePhysicObject(v)
- gnum = gnum - 1
- end
- players[name] = nil
- end
- function getPlayerNumber()
- local n = 0
- for k,v in pairs(players) do
- n = n + 1
- end
- return n
- end
- function eventMouse(name, x, y)
- if players[name].hold and players[name].started_drawing then
- players[name].firstPoint = players[name].lastPoint
- players[name].lastPoint = {x=x, y=y}
- role_f[players[name].mode](name, players[name].firstPoint.x,players[name].firstPoint.y,players[name].lastPoint.x,players[name].lastPoint.y)
- players[name].firstPoint = nil
- elseif players[name].firstPoint then
- players[name].lastPoint = {x=x, y=y}
- role_f[players[name].mode](name, players[name].firstPoint.x,players[name].firstPoint.y,players[name].lastPoint.x,players[name].lastPoint.y)
- players[name].firstPoint = nil
- players[name].started_drawing = true
- else
- players[name].firstPoint = {x=x, y=y}
- end
- end
- function ground_draw(name, x, y, x2, y2)
- if players[name].laser then
- for i=players[name].laser.start, players[name].laser.stop do
- gnum = gnum - 1
- tfm.exec.removePhysicObject(i)
- end
- end
- local num = math.ceil(430/(getPlayerNumber()*2.5))
- local xlenght = x2-x
- local ylenght = y2-y
- local lenght = math.sqrt((xlenght^2)+(ylenght^2))
- local angle = math.deg(math.atan(ylenght/xlenght))
- local ground = prot[players[name].gtype] or {}
- ground.width = 10
- ground.height = players[name].height
- ground.angle = angle
- ground.color = players[name].color
- players[name].laser = {start = id}
- for i=0,num do
- local lx = xlenght/num * i + x
- local ly = ylenght/num * i + y
- local lx = math.abs(lx)
- local ly = math.abs(ly)
- if gnum < 430 then
- players[name].ids[#players[name].ids+1] = id
- tfm.exec.addPhysicObject(id, lx, ly, ground)
- id = id + 1
- gnum = gnum + 1
- else
- break
- end
- end
- players[name].laser.stop = id
- end
- function whole_ground_draw(name, x, y, x2, y2)
- local num = 30
- local xlenght = x2-x
- local ylenght = y2-y
- local lenght = math.sqrt((xlenght^2)+(ylenght^2))
- local angle = math.deg(math.atan(ylenght/xlenght))
- local joint = {
- type=0,
- point1=x..","..y,
- point2=x2..","..y2,
- frequency=10,
- damping=0.2,
- line=5,
- color= 0xFF2222,
- alpha=1,
- foreground=true
- }
- local lx = x+xlenght/2
- local ly = y+ylenght/2
- local width = lenght
- local ground = prot[players[name].gtype] or {}
- ground.angle = angle
- ground.width = width
- ground.height = players[name].height
- ground.color = players[name].color
- if gnum < 430 then
- players[name].ids[#players[name].ids+1] = id
- tfm.exec.addPhysicObject(id , lx, ly, ground)
- id = id + 1
- gnum = gnum + 1
- end
- end
- function eventChatCommand(name, cmd)
- local args = {}
- for arg in string.gmatch(cmd, "[%S]+") do
- args[#args+1] = arg
- end
- if args[1] == "undo" then
- if type(tonumber(args[2]))=="number" then
- local num = (#players[name].ids - tonumber(args[2])+1)>=1 and (#players[name].ids-tonumber(args[2])+1) or 1
- for i=#players[name].ids,num, -1 do
- tfm.exec.removePhysicObject(players[name].ids[i])
- players[name].ids[i] = nil
- gnum = gnum - 1
- end
- elseif args[2] == "all" then
- for i=1,#players[name].ids do
- tfm.exec.removePhysicObject(players[name].ids[i])
- players[name].ids[i] = nil
- gnum = gnum - 1
- end
- else
- tfm.exec.removePhysicObject(players[name].ids[#players[name].ids])
- players[name].ids[#players[name].ids] = nil
- gnum = gnum - 1
- end
- elseif args[1] == "clear" and name == admin then
- for i=1,id do
- tfm.exec.removePhysicObject(i)
- gnum = gnum - 1
- end
- for k,v in pairs(players) do
- players[k].ids = {}
- end
- elseif args[1] == "set" then
- if args[2] == "mode" then
- if role_f[args[3]] then
- players[name].mode = args[3]
- end
- elseif args[2] == "ground" then
- if tonumber(args[3]) then
- players[name].gtype = args[3]
- elseif grounds[args[3]] then
- players[name].gtype = grounds[args[3]]
- end
- elseif args[2] == "color" then
- ui.showColorPicker(1, name, players[name].color, "Choose!")
- elseif args[2] == "height" then
- if tonumber(args[3]) then
- players[name].height = tonumber(args[3])
- end
- end
- end
- end
- function eventColorPicked(id ,name, color)
- if id == 1 then
- players[name].color = color
- end
- end
- function init()
- role_f = {
- many = ground_draw,
- whole = whole_ground_draw,
- }
- end
- init()
- for k,v in pairs({"set", "undo", "clear"}) do system.disableChatCommandDisplay(v, true) end
- for k,v in pairs(tfm.get.room.playerList) do eventNewPlayer(k) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement