Advertisement
Jackson_Pike

Reactor Hatch

Apr 8th, 2022
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. if fs.exists("pikeLib") then
  2.   exists = true
  3. else
  4.   shell.run("pastebin get nXvVUSuw pikeLib")
  5. end
  6.  
  7. if exists then
  8.   print(os.loadAPI("pikeLib"))
  9. else
  10.   term.clear()
  11.   term.setCursorPos(1, 1)
  12.   term.setTextColor(colors.red)
  13.   print("Missing dependences...pikeLib API not found")
  14.   os.exit()
  15. end
  16.  
  17. term.clear()
  18. term.setCursorPos(1, 1)
  19. term.write("Attempting to attach monitor...")
  20. -------------
  21. local dsp = pikeLib.fetchPeripheral()
  22. if test == "FAILED" then
  23.   term.setTextColor(colors.red)
  24.   print("FAILED")
  25.   os.exit()
  26. else
  27.   term.setTextColor(colors.green)
  28.   term.write("Success!")
  29. end
  30.  
  31. dsp.setTextScale(0.75)
  32. redstone.setAnalogOutput("bottom", 0)
  33. doorOpen = false
  34.  
  35. function printDisplay()
  36.   monx, mony = dsp.getSize()
  37.   dsp.setBackgroundColor(colors.black)
  38.   dsp.clear()
  39.   dsp.setTextColor(colors.white)
  40.   dsp.setCursorPos(1, 1)
  41.   dsp.setBackgroundColor(colors.gray)
  42.   dsp.write(string.rep(" ", monx))
  43.   dsp.setCursorPos(1, mony)
  44.   dsp.write(string.rep(" ", monx))
  45.   dsp.setBackgroundColor(colors.black)
  46.   dsp.setTextColor(colors.red)
  47.   dsp.setCursorPos(1, 3)
  48.  
  49.   dsp.setBackgroundColor(colors.black)
  50.   dsp.clear()
  51.  
  52.   pikeLib.drawBars(colors.blue, 1, dsp)
  53.   pikeLib.drawBars(colors.blue, mony, dsp)
  54.  
  55.  
  56.   if doorOpen then
  57.     printText = "Close Reactor Hatch"
  58.   else
  59.     printText = "Open Reactor Hatche"
  60.   end
  61.  
  62.   pikeLib.easyWrite(pikeLib.Positions[5],
  63.    colors.black, colors.red, printText, dsp)
  64. end
  65. printDisplay()
  66.  
  67. repeat
  68.   event, side, xpos, ypos = os.pullEvent("monitor_touch")
  69.   if side == "top" then
  70.     pikeLib.toggleRedstone("bottom")
  71.     if doorOpen then
  72.       doorOpen = false
  73.     else
  74.       doorOpen = true
  75.     end
  76.     printDisplay()
  77.   end
  78. until false
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement