BombBloke

partTerm Example - Floating Bomberman

May 21st, 2016
60
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if not partTerm then
  2.     if not (fs.exists("partTerm") or fs.exists(shell.resolve("partTerm"))) then
  3.         shell.run("pastebin get hR8p9ML4 partTerm")
  4.         os.loadAPI(shell.resolve("partTerm"))
  5.     else os.loadAPI(fs.exists("partTerm") and "partTerm" or shell.resolve("partTerm")) end
  6. end
  7.  
  8. partTerm.removeAll()
  9. partTerm.setDensity(30)
  10.  
  11. local bombHead = {"aaeeeaa", "a00000a", "0444440", "04f4f40", "04f4f40", "04f4f40", "0444440", "a00000a"}
  12. local bombBody = {"a8bbb8a", "eaf1fae", "aabbbaa", "aa8a8aa", "aa8a8aa", "aaeaeaa"}
  13.  
  14. local x, y, z = commands.getBlockPosition()
  15. x, y, z = x + 0.5, y + 0.5, z + 0.5  -- 'cause we're interested in the center of the block.
  16.  
  17. local headWin = partTerm.createWindow(x, y + 2.5, z, 7, 8, colours.purple)
  18. local bodyWin = partTerm.createWindow(x, y + 1.1, z, 7, 6, colours.purple)
  19.  
  20. for i = 1, 8 do
  21.     headWin.setCursorPos(1, i)
  22.     headWin.blit(nil, nil, bombHead[i])
  23. end
  24.  
  25. for i = 1, 6 do
  26.     bodyWin.setCursorPos(1, i)
  27.     bodyWin.blit(nil, nil, bombBody[i])
  28. end
  29.  
  30. headWin.setParticle("reddust")
  31.  
  32. parallel.waitForAny(
  33.     function()
  34.         while true do
  35.             local state, result = commands.tp("@p ~ ~ ~")
  36.  
  37.             if state then
  38.                 -- Match taken from: http://www.computercraft.info/forums2/index.php?/topic/24581-command-utils-get-players-coordinates-and-more/
  39.                 local pX, pY, pZ = result[1]:match( "Teleported %S+ to (.?%d+%.?%d*),(.?%d+%.?%d*),(.?%d+%.?%d*)" )
  40.  
  41.                 local rotHori = partTerm.getHorizontalAngle(x, z, pX, pZ) + 90
  42.                 local rotVert = partTerm.getVerticalAngle(x, y, z, pX, pY, pZ) - 90
  43.                
  44.                 headWin.setAngles(rotHori, rotVert)
  45.                 bodyWin.setAngles(rotHori, 0)
  46.             end
  47.            
  48.             sleep(0.5)
  49.         end
  50.     end,
  51.    
  52.     partTerm.render
  53. )
RAW Paste Data