skypop

look (computer)

Sep 11th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. term.setBackgroundColor(colors.black)
  2. term.setTextColor(colors.white)
  3.  
  4. local wi = peripheral.find("WorldInterface")
  5. if not wi then
  6.   if not os.loadAPI("apis/lip")
  7.   or not lip then
  8.     error("Cant find World Interface",0)
  9.   else
  10.     wi = lip.WorldInterface
  11.   end
  12. end
  13.  
  14. local x,y,z = gps.locate()
  15.  
  16. if not x then
  17.   term.setCursorPos(1,1)
  18.   term.clear()
  19.   term.setCursorBlink(true)
  20.   term.write("X=")
  21.   x = tonumber(read())
  22.   term.setCursorPos(1,2)
  23.   term.write("Y=")
  24.   y = tonumber(read())
  25.   term.setCursorPos(1,3)
  26.   term.write("Z=")
  27.   z = tonumber(read())
  28.   term.setCursorBlink(false)
  29. end
  30.  
  31. x = math.floor(x)
  32. y = math.floor(y)
  33. z = math.floor(z)
  34.  
  35. local function displayHelp()
  36.   term.setBackgroundColor(colors.black)
  37.   term.setTextColor(colors.white)
  38.   term.setCursorPos(1,1)
  39.   term.clear()
  40.   print(string.format([[Controls:
  41. %s West  (-x) [right]
  42. %s North (-z) [up]
  43. %s East  (+x) [left]
  44. %s South (+z) [down]
  45. %s Down  (-y) [pageDown]
  46. %s Up    (+y) [pageUp]
  47. %s
  48. R Refresh
  49. H Help
  50. Q Quit]],
  51. string.char(27),
  52. string.char(24),
  53. string.char(26),
  54. string.char(25),
  55. string.char(31),
  56. string.char(30),
  57. string.rep(string.char(140),25)))
  58.   sleep(.5)
  59.   os.pullEvent("key")
  60.   sleep(.2)
  61. end
  62.  
  63. local function pos()
  64.   term.setCursorPos(1,1)
  65.   term.clearLine()
  66.   term.write(string.format([[X:%d, Y:%d, Z:%d]],x,y,z))
  67.   term.setCursorPos(1,2)
  68. end
  69. local getDatatags = false
  70. while true do
  71.   term.setBackgroundColor(colors.black)
  72.   term.setTextColor(colors.white)
  73.   term.clear()
  74.   pos()
  75.   local o = getDatatags and wi.getBlockDatatags(x,y,z) or wi.getBlockInfos(x,y,z)
  76.   textutils.pagedPrint(textutils.serialise(o))
  77.   getDatatags = false
  78.   while true do
  79.     sleep(.1)
  80.     local e,p = os.pullEvent("key")
  81.     --refresh
  82.     if p==keys.r or p==keys.enter then
  83.       break
  84.     elseif p==keys.up then
  85.       z = z-1
  86.       pos()
  87.     elseif p==keys.down then
  88.       z = z+1
  89.       pos()
  90.     elseif p==keys.right then
  91.       x = x+1
  92.       pos()
  93.     elseif p==keys.left then
  94.       x = x-1
  95.       pos()
  96.     elseif p==keys.pageDown then
  97.       y = math.max(1,y-1)
  98.       pos()
  99.     elseif p==keys.pageUp then
  100.       y = y+1
  101.       pos()
  102.     elseif p==keys.numPadAdd then
  103.       getDatatags = true
  104.       break
  105.     elseif p==keys.h then
  106.       displayHelp()
  107.       break
  108.     elseif p==keys.q then
  109.       sleep(.3)
  110.       error("Terminated",0)
  111.       return
  112.     end
  113.   end
  114. end
Add Comment
Please, Sign In to add comment