Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Model = { type = 0, width = 50, height = 0, foreground = false,
- friction =0.3, restitution = 0.3, angle = 0,
- color = tonumber("FF0056", 16),
- miceCollision = true, groundCollision = true,
- dynamic = false, fixedRotation = false, mass = 50,
- linearDamping = 0, angularDamping = 0 }
- objID = 0
- playID = 0
- Players = {}
- function eventNewPlayer(k)
- playID = playID + 1
- system.bindMouse(k, true)
- Players[k] = {}
- Players[k].plank = Model
- Players[k].rest = 700
- Players[k].id = playID
- Players[k].objs = {}
- for k,v in pairs({66, 78}) do
- tfm.exec.bindKeyboard(k, v, true, true)
- end
- end
- for k,v in pairs(tfm.get.room.playerList) do
- eventNewPlayer(k)
- end
- function eventChatCommand(name, cmd)
- local args = {}
- for arg in cmd:gmatch("[^%s]+") do
- table.insert(args, arg)
- end
- if args[1]=="ro" then
- Players[name].plank.angle = tonumber(args[2])
- end
- if args[1]=="clear" then
- for k,v in pairs(Players[name].objs) do
- tfm.exec.removePhysicObject(v)
- end
- Players[name].objs = {}
- end
- if args[1]=="undo" then
- if args[2] then
- for i=tonumber(math.abs(args[2])),1,-1 do
- tfm.exec.removePhysicObject(Players[name].objs[#Players[name].objs])
- table.remove(Players[name].objs, #Players[name].objs)
- end
- else
- tfm.exec.removePhysicObject(Players[name].objs[#Players[name].objs])
- table.remove(Players[name].objs)
- end
- end
- end
- function eventMouse(name, x, y)
- if Players[name].rest <=0 then
- local ans = "<font face='Soopafresh' size='20'>You have no more planks left, you can use undo to remove the last object spawned "
- ui.addPopup(Players[name].id, 0, name, ans, 100, 50, 200, true)
- return
- end
- objID = objID + 1
- tfm.exec.addPhysicObject(objID, x, y, Players[name].plank)
- Players[name].objs[#Players[name].objs+1] = objID
- Players[name].rest = Players[name].rest - 1
- end
- -- This part below doesn't work, you can fix it if you want.
- function eventKeyboard(name, keycode, down, x, y)
- if keycode==78 then -- here, keycode isn't detected
- Players[name].plank.angle = Players[name].plank.angle + 5
- elseif keycode==66 then
- Players[name].plank.angle = Players[name].plank.angle -5
- end
- tfm.exec.addShamanObject(0, x+20, y, Players[name].plank.angle)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement