Fooksie

#recordbuild

May 27th, 2014
1,192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.76 KB | None | 0 0
  1. def={}
  2. joints={}
  3. dodraw=true
  4. timeleft=0
  5. timeadded=0
  6. def[1]={30, 30}
  7. def[2]={60, 60}
  8. def[3]={100, 10}
  9. def[4]={200, 10}
  10. def[6]={30, 30}
  11. function eventLoop(time, remaining)
  12.     timeleft=remaining
  13.     if dodraw then
  14.         local o
  15.         for i=1, #joints do
  16.             o=tfm.get.room.objectList[joints[i][1]]
  17.             if o then
  18.                 tfm.exec.addJoint(i*3+2, 255, 255, {
  19.                     point1=joints[i][4],
  20.                     point2=math.floor(o.x)..","..math.floor(o.y),
  21.                     line=1,
  22.                     color=0xffffff,
  23.                     alpha=0.5,
  24.                     foreground=true
  25.                     })
  26.                 end
  27.             end
  28.         end
  29.     end
  30. function eventNewGame()
  31.     clearJoints()
  32.     joints={}
  33.     timeadded=0
  34.     tfm.exec.addPhysicObject(255, 0, 800, {
  35.         miceCollision=false,
  36.         groundCollision=false
  37.         })
  38.     end
  39. function eventNewPlayer(name)
  40.     tfm.exec.bindKeyboard(name, 73, true, true)
  41.     tfm.exec.bindKeyboard(name, 79, true, true)
  42.     tfm.exec.bindKeyboard(name, 85, true, true)
  43.     end
  44. function eventKeyboard(name, key)
  45.     if tfm.get.room.playerList[name].isShaman then
  46.         if key==73 then
  47.             timeleft=timeleft+30000
  48.             timeadded=timeadded+30
  49.             tfm.exec.setGameTime(math.floor(timeleft/1000))
  50.         elseif key==79 then
  51.             for _name, player in pairs(tfm.get.room.playerList) do
  52.                 if _name~=name then
  53.                     tfm.exec.setPlayerScore(_name, -1, false)
  54.                     end
  55.                 end
  56.             tfm.exec.newGame(tfm.get.room.currentMap)
  57.         elseif key==85 then
  58.             dodraw=not dodraw
  59.             if dodraw then drawJoints()
  60.             else clearJoints() end
  61.             end
  62.         end
  63.     end
  64. function drawJoints()
  65.     ui.addTextArea(999, "<font color='#000000'>+"..timeadded.."s", nil, 6, 28,
  66.         nil, nil, 0, 0, 0, true)
  67.     for i=1, #joints do
  68.         ui.addTextArea(i, "<font color='#000000'>"..i, nil, joints[i][2], joints[i][3],
  69.             nil, nil, 0, 0, 0, true)
  70.         tfm.exec.addJoint(i*3, 255, 255, {
  71.             point1=joints[i][6],
  72.             point2=joints[i][7],
  73.             line=joints[i][8],
  74.             color=0x00ff00,
  75.             alpha=0.3
  76.             })
  77.         tfm.exec.addJoint(i*3+1, 255, 255, {
  78.             point1=joints[i][4],
  79.             point2=joints[i][5],
  80.             line=20,
  81.             color=0xffffff,
  82.             alpha=0.6,
  83.             foreground=true
  84.             })
  85.         end
  86.     end
  87. function clearJoints()
  88.     ui.removeTextArea(999)
  89.     for i=1, #joints do
  90.         ui.removeTextArea(i)
  91.         tfm.exec.removeJoint(i*3)
  92.         tfm.exec.removeJoint(i*3+1)
  93.         tfm.exec.removeJoint(i*3+2)
  94.         end
  95.     end
  96. function eventSummoningEnd(name, type, x, y, angle, xs, ys, data, other)
  97.     if def[type] then
  98.         angle=angle/180*math.pi
  99.         local p=def[type]
  100.         local d=p[1]/2-p[2]/2
  101.         local p1, p2=math.floor(math.cos(angle)*d), math.floor(math.sin(angle)*d)
  102.         if p1==p2 then p2=p2+1 end
  103.         table.insert(joints, {
  104.             data.id,
  105.             x-5, y-6,
  106.             x..","..y,
  107.             x..","..(y+1),
  108.             (x+p1)..","..(y+p2),
  109.             (x-p1)..","..(y-p2),
  110.             p[2]
  111.             })
  112.         if dodraw then drawJoints() end
  113.         end
  114.     end
  115. tfm.exec.disableAutoTimeLeft(true)
  116. for name, player in pairs(tfm.get.room.playerList) do
  117.     eventNewPlayer(name)
  118.     end
Advertisement
Add Comment
Please, Sign In to add comment