Advertisement
Guest User

zachdial

a guest
Apr 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. local teleinfo = {
  2. {"Noah Void Base", colors.blue},
  3. {"Elissa Void Base", colors.magenta},
  4. {"John Void Base", colors.white},
  5. {"Emily Void Base", colors.lime},
  6. {"End", colors.gray},
  7. {"Nether", colors.lightBlue},
  8. {"Quarry", colors.pink},
  9. {"Overworld", colors.lightGray},
  10. {"Hungry Node", colors.purple},
  11. }
  12. local yoffset = 2
  13. local mon = peripheral.wrap("right")
  14. local bc = "bottom"
  15.  
  16. local y = nil
  17. local function newline() y=y+1; mon.setCursorPos(1, y) end
  18.  
  19. local function flashBundled(color)
  20. rs.setBundledOutput(bc, color)
  21. sleep(.1)
  22. rs.setBundledOutput(bc, 0)
  23. end
  24.  
  25. local lastTele = nil
  26. local function closeTele()
  27. lastTele = nil
  28. flashBundled(colors.orange)
  29. end
  30.  
  31. local function redraw()
  32. mon.setCursorPos(1, 1)
  33. y = 1
  34. mon.setBackgroundColor(colors.black)
  35. mon.setTextColor(colors.white)
  36. mon.clear()
  37. mon.write("Teleporter Dialer")
  38. newline()
  39. newline()
  40.  
  41. for i,v in pairs(teleinfo) do
  42. if lastTele == i then
  43. mon.setTextColor(colors.white)
  44. mon.setBackgroundColor(v[2])
  45. else
  46. mon.setTextColor(v[2])
  47. mon.setBackgroundColor(colors.black)
  48. end
  49. mon.write(" " .. i .. " " .. v[1])
  50. newline()
  51. end
  52. end
  53.  
  54. -- returns true if the teleporter was opened
  55.  
  56. local function teleporter(index)
  57. if not teleinfo[index] then
  58. closeTele()
  59. return false
  60. end
  61. print("Starting up " .. teleinfo[index][1])
  62. color = teleinfo[index][2]
  63. flashBundled(color)
  64. lastTele = index
  65. return true
  66. end
  67.  
  68. local autocloseTimer = nil
  69. while true do
  70. redraw()
  71. local ev = {os.pullEvent()}
  72. if ev[1] == "monitor_touch" then
  73. if teleporter(ev[4] - yoffset) then
  74. autocloseTimer = os.startTimer(30)
  75. else
  76. autocloseTimer = nil
  77. end
  78. elseif ev[1] == "redstone" then
  79. autocloseTimer = os.startTimer(10)
  80. elseif ev[1] == "timer" then
  81. if ev[2] == autocloseTimer then
  82. closeTele()
  83. end
  84. end
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement