Advertisement
Hachem16

Build & Draw

Jun 2nd, 2014
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. Model = { type = 0, width = 50, height = 0, foreground = false,
  2.              friction =0.3,  restitution = 0.3, angle = 0,
  3.              color = tonumber("FF0056", 16),
  4.              miceCollision = true, groundCollision = true,
  5.              dynamic = false, fixedRotation = false, mass = 50,
  6.              linearDamping = 0, angularDamping = 0 }
  7. objID = 0
  8. playID = 0
  9. Players = {}
  10. function eventNewPlayer(k)
  11.     playID = playID + 1
  12.     system.bindMouse(k, true)
  13.     Players[k] = {}
  14.     Players[k].plank = Model
  15.     Players[k].rest = 700
  16.     Players[k].id = playID
  17.     Players[k].objs = {}
  18.     for k,v in pairs({66, 78}) do
  19.         tfm.exec.bindKeyboard(k, v, true, true)
  20.     end
  21. end
  22. for k,v in pairs(tfm.get.room.playerList) do
  23.     eventNewPlayer(k)
  24. end
  25.  
  26. function eventChatCommand(name, cmd)
  27.     local args = {}
  28.     for arg in cmd:gmatch("[^%s]+") do
  29.         table.insert(args, arg)
  30.     end
  31.     if args[1]=="ro" then
  32.         Players[name].plank.angle = tonumber(args[2])
  33.     end
  34.     if args[1]=="clear" then
  35.         for k,v in pairs(Players[name].objs) do
  36.             tfm.exec.removePhysicObject(v)
  37.         end
  38.         Players[name].objs = {}
  39.     end
  40.     if args[1]=="undo" then
  41.         if args[2] then
  42.             for i=tonumber(math.abs(args[2])),1,-1 do
  43.                 tfm.exec.removePhysicObject(Players[name].objs[#Players[name].objs])
  44.                 table.remove(Players[name].objs, #Players[name].objs)
  45.             end
  46.         else
  47.             tfm.exec.removePhysicObject(Players[name].objs[#Players[name].objs])
  48.             table.remove(Players[name].objs)
  49.         end
  50.     end
  51. end
  52. function eventMouse(name, x, y)
  53.     if Players[name].rest <=0 then
  54.         local ans =  "<font face='Soopafresh' size='20'>You have no more planks left, you can use undo to remove the last object spawned "
  55.         ui.addPopup(Players[name].id, 0, name, ans, 100, 50, 200, true)
  56.         return
  57.     end
  58.     objID = objID + 1
  59.     tfm.exec.addPhysicObject(objID, x, y, Players[name].plank)
  60.     Players[name].objs[#Players[name].objs+1] = objID
  61.     Players[name].rest = Players[name].rest - 1
  62. end
  63.  
  64.  
  65.  
  66. -- This part below doesn't work, you can fix it if you want.
  67. function eventKeyboard(name, keycode, down, x, y)
  68.     if keycode==78 then -- here, keycode isn't detected
  69.         Players[name].plank.angle = Players[name].plank.angle + 5
  70.     elseif keycode==66 then
  71.         Players[name].plank.angle = Players[name].plank.angle -5
  72.     end
  73.     tfm.exec.addShamanObject(0, x+20, y, Players[name].plank.angle)
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement