Advertisement
Bolodefchoco_LUAXML

[Script] Build Recorder

May 6th, 2016
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.28 KB | None | 0 0
  1. --Creator: Bolodefchoco (previously Fxie)
  2. --Made in: 06/05/2016
  3. --Last update: 26/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Grava a construção o shaman utilizando joints
  7.     Commands:
  8.         !
  9.             time --> Altera o tempo
  10.                 int --> Tempo em minutos
  11.             color --> Muda a cor da joint caso você seja o shaman
  12.             clear --> Remove objetos/joints
  13.                 ? --> Caso tenha um segundo argumento, apenas os objetos serão deletados, poupando as joints.
  14. ]]--
  15.  
  16. lines={}
  17. object={
  18.     [1] = {30,30}, --box 1
  19.     [2] = {60,60}, --box 2
  20.     [3] = {100,10}, --plank 1
  21.     [4] = {200,10}, --plank 2
  22.     [6] = {30,30}, --ball
  23.     [7] = {100,20}, --trampoline
  24.     [10] = {50,25}, --anvil
  25.     [57] = {80,55}, --cloud
  26.     [60] = {50,10}, --tiny plank
  27.     [61] = {50,50}, --companion crate
  28.     [67] = {305,10}, --big plank
  29.     [68] = {90,70}, --triangle
  30. }
  31.  
  32. able_drawLine=true
  33. shaman_colour = 0x00ff00
  34.  
  35. eventLoop=function(currentTime)
  36.     if able_drawLine then
  37.         local o
  38.         for i=1,#lines do
  39.             o=tfm.get.room.objectList[lines[i][1]]
  40.             if o then
  41.                 tfm.exec.addJoint(i*3+2,255,255,{
  42.                     point1=lines[i][4],
  43.                     point2=math.floor(o.x)..","..math.floor(o.y),
  44.                     line=1,
  45.                     color=0xffffff,
  46.                     alpha=.5,
  47.                     foreground=true
  48.                 })
  49.             end
  50.         end
  51.     end
  52. end
  53.  
  54. eventNewGame=function()
  55.     clear()
  56.     lines={}
  57.     shaman_colour = 0x00ff00
  58.     tfm.exec.addPhysicObject(255,0,800,{
  59.         miceCollision=false,
  60.         groundCollision=false
  61.     })
  62. end
  63.  
  64. draw=function()
  65.     for i=1, #lines do
  66.         ui.addTextArea(i,"<font color='#000000'>"..i,n,lines[i][2],lines[i][3],nil,nil,0,0,0,false)
  67.         tfm.exec.addJoint(i*3,255,255,{
  68.             point1=lines[i][6],
  69.             point2=lines[i][7],
  70.             line=lines[i][8],
  71.             color=shaman_colour,
  72.             alpha=.3
  73.         })
  74.         tfm.exec.addJoint(i*3+1,255,255,{
  75.             point1=lines[i][4],
  76.             point2=lines[i][5],
  77.             line=20,
  78.             color=0xffffff,
  79.             alpha=0.6,
  80.             foreground=true
  81.         })
  82.     end
  83. end
  84.  
  85. clear=function()
  86.     for i=1,#lines do
  87.         ui.removeTextArea(i)
  88.         tfm.exec.removeJoint(i*3)
  89.         tfm.exec.removeJoint(i*3+1)
  90.         tfm.exec.removeJoint(i*3+2)
  91.     end
  92. end
  93.  
  94. eventSummoningEnd=function(n,o,x,y,a,xs,ys,set)
  95.     local objectReplace = {
  96.         [1] = {100,200},
  97.         [2] = {200,300},
  98.         [3] = {300,400},
  99.         [4] = {400,600},
  100.         [6] = {600,700},
  101.         [7] = {700,800},
  102.         [10] = {1000,1700}
  103.     }
  104.     for k,v in next,objectReplace do
  105.         if o>v[1] and o<v[2] then
  106.             o = k
  107.             break
  108.         end
  109.     end
  110.     if object[o] then
  111.         local angle=a/180*math.pi
  112.         local obj=object[o]
  113.         local dir=obj[1]/2-obj[2]/2
  114.         local p1,p2=math.floor(math.cos(angle)*dir),math.floor(math.sin(angle)*dir)
  115.         if p1==p2 then p2=p2+1 end
  116.         table.insert(lines,{
  117.             set.id,
  118.             x-5,y-6,
  119.             x..","..y,
  120.             x..","..(y+1),
  121.             (x+p1)..","..(y+p2),
  122.             (x-p1)..","..(y-p2),
  123.             obj[2]
  124.             })
  125.         if able_drawLine then draw() end
  126.     end
  127. end
  128.  
  129. eventChatCommand=function(n,c)
  130.     if tfm.get.room.playerList[n].isShaman then
  131.         if c:lower():sub(1,4)=="time" then
  132.             tfm.exec.setGameTime(tonumber(c:sub(6))*60)
  133.         end
  134.         if c:lower() == "color" then
  135.             ui.showColorPicker(0,n,shaman_colour,"Recorder Color")
  136.         end
  137.         if c:lower():sub(1,5) == "clear" then
  138.             local idList={}
  139.             for id in next,tfm.get.room.objectList do table.insert(idList,id) end
  140.             for k,v in next,idList do tfm.exec.removeObject(v) end
  141.             idList={}
  142.             if c:lower():sub(7)=="" then clear();lines={} end
  143.         end
  144.     end
  145. end
  146.  
  147. eventColorPicked=function(i,n,c) shaman_colour = c end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement