Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Cage In The House (multi-ppl version)
- --change the size of the cage
- cageSize=60
- players = {}
- nextGroundID = 1001
- bodyDef = {
- type = 0,
- width = 60,
- height = 10,
- foreground = false,
- friction = 0.3,
- restitution = 0.2,
- angle = 0,
- color = 0xffffff,
- miceCollision = true,
- groundCollision = false,
- dynamic = false,
- fixedRotation = true,
- mass = 0,
- linearDamping = 0,
- angularDamping = 0
- }
- colors = {
- red = "0xFF0000",
- pink = "0xFFC0CB",
- purple = "0x800080",
- chocolate = "0xD2691E",
- orangered = "0xFF4500",
- tomato = "0xFF6347",
- gold = "0xFFD700",
- yellow = "0xFFFF00",
- lightyellow = "0xFFFFE0",
- olive = "0x808000",
- darkgreen = "0x006400",
- forestgreen = "0x228B22",
- lightseagreen = "0x20B2AA",
- lime = "0x00FF00",
- aquamarine = "0x7FFFD4",
- blue = "0x0000FF",
- cyan = "0x00FFFF",
- black = "0x000000",
- gray = "0x808080",
- white = "0xFFFFFF"
- }
- function inColorTable(str)
- for k,v in pairs(colors) do
- if k==str then return true end
- end
- return false
- end
- function eventNewPlayer(name)
- for i,key in ipairs({40,83}) do
- tfm.exec.bindKeyboard(name,key,true,true)
- end
- table.insert(players, name)
- players[name] = {
- color = "default",
- groundID = nextGroundID,
- lastX = 0,
- lastY = 0
- }
- nextGroundID = nextGroundID + 4
- end
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- function eventKeyboard(name,key,down,x,y)
- players[name].lastX = x
- players[name].lastY = y
- if players[name].color == "default" then
- bodyDef.type = 0
- else
- bodyDef.type = 12
- bodyDef.color = players[name].color
- end
- -- up and down ground
- tfm.exec.removePhysicObject(players[name].groundID)
- bodyDef.width=cageSize
- bodyDef.height=10
- bodyDef.miceCollision = true
- tfm.exec.addPhysicObject(players[name].groundID, x, y+20, bodyDef)
- tfm.exec.removePhysicObject(players[name].groundID+3)
- tfm.exec.addPhysicObject(players[name].groundID+3, x, y-cageSize+30, bodyDef)
- -- left and right ground
- tfm.exec.removePhysicObject(players[name].groundID+1)
- bodyDef.width=10
- bodyDef.height=cageSize
- bodyDef.miceCollision = true
- tfm.exec.addPhysicObject(players[name].groundID+1, x-cageSize/2+5, y-cageSize/2+25, bodyDef)
- tfm.exec.removePhysicObject(players[name].groundID+2)
- tfm.exec.addPhysicObject(players[name].groundID+2, x+cageSize/2-5, y-cageSize/2+25, bodyDef)
- end
- function eventEmotePlayed(name,emote)
- if emote==3 then
- bodyDef.type=8
- -- up and down ground
- tfm.exec.removePhysicObject(players[name].groundID)
- bodyDef.width=cageSize
- bodyDef.height=10
- bodyDef.miceCollision = false
- tfm.exec.addPhysicObject(players[name].groundID, players[name].lastX, players[name].lastY+20, bodyDef)
- tfm.exec.removePhysicObject(players[name].groundID+3)
- tfm.exec.addPhysicObject(players[name].groundID+3, players[name].lastX, players[name].lastY-cageSize+30, bodyDef)
- -- left and right ground
- tfm.exec.removePhysicObject(players[name].groundID+1)
- bodyDef.width=10
- bodyDef.height=cageSize
- bodyDef.miceCollision = false
- tfm.exec.addPhysicObject(players[name].groundID+1, players[name].lastX-cageSize/2+5, players[name].lastY-cageSize/2+25, bodyDef)
- tfm.exec.removePhysicObject(players[name].groundID+2)
- tfm.exec.addPhysicObject(players[name].groundID+2, players[name].lastX+cageSize/2-5, players[name].lastY-cageSize/2+25, bodyDef)
- end
- end
- function eventChatCommand(name, command)
- args = {}
- num=1
- for word in string.gmatch(command, "%w+") do
- args[num] = word
- num = num + 1
- end
- if args[1] == "color" then
- if inColorTable(args[2]) then
- players[name].color = colors[args[2]]
- else
- players[name].color = args[2]
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement