Advertisement
AlexMastang

Untitled

Oct 7th, 2022
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.70 KB | None | 0 0
  1. local laser = peripheral.find("laserAmplifier")
  2. local pw_confirm = "1234"
  3. local i = 1
  4. local max = 75
  5. local r = 3
  6.  
  7. -- The configuration of the computer should be:
  8. -- Left side of redstone: toggle the cables
  9. -- Right side of redstone: toggle the laser amplifier
  10. -- 2 modems are rquired, connecting the computer to the amplifier
  11.  
  12. local function Charging()
  13.     textutils.slowPrint("Starting up charging unit", time)
  14.     rs.setOutput("left", true)
  15.     i = i + 3
  16.     laser_energy = laser.getEnergy() * 100 / laser.getMaxEnergy()
  17.     while laser_energy < max do
  18.         laser_energy = laser.getEnergy() * 100 / laser.getMaxEnergy()
  19.         term.setCursorPos(1, i)
  20.         term.clearLine()
  21.         textutils.slowPrint("...", 5)
  22.         term.setCursorPos(1, i+1)
  23.         print(laser_energy .. "%")
  24.         term.clearLine()
  25.         os.sleep(0.1)
  26.     end
  27.     rs.setOutput("left", false)
  28.     textutils.slowPrint("Module charged at " .. max .. "%", time)
  29. end
  30.  
  31. ----------------------------------------------------------------------------------
  32.  
  33. local function EndProcess()
  34.     textutils.slowPrint("Ignition in", time)
  35.     while r > 0 do
  36.         print(r)
  37.         r = r - 1
  38.         os.sleep(1)
  39.     end
  40.     rs.setOutput("right", true)
  41.     os.sleep(1)
  42.     rs.setOutput("right", false)
  43.     textutils.slowPrint("The module has been fired", time)
  44. end
  45.  
  46. ----------------------------------------------------------------------------------
  47.  
  48. local function PasswordConfirmedAuto()
  49.     Charging()
  50.     EndProcess()
  51. end
  52.  
  53. ----------------------------------------------------------------------------------
  54.  
  55. local function PasswordConfirmedManual()
  56.     Charging()
  57.     textutils.slowWrite("Fire?: ", time)
  58.     firing = read()
  59.     EndProcess()
  60. end
  61.  
  62. ----------------------------------------------------------------------------------
  63.  
  64. while true do
  65.     term.clear()
  66.     term.setCursorPos(1, 1)
  67.     print("PAD Online")
  68.     os.sleep(1)
  69.     print("---------------")
  70.     i = i + 3
  71.     term.setCursorPos(1, i)
  72.     textutils.slowWrite("Insert password to power up the module: ", time)
  73.     pw = read("*")
  74.    
  75.     if pw == pw_confirm then
  76.         i = i + 1
  77.         term.setCursorPos(1, i)
  78.         textutils.slowPrint("The password has been confirmed", time)
  79.         os.sleep(1)
  80.         i = i + 3
  81.         term.setCursorPos(1, i)
  82.         while true do
  83.             textutils.slowWrite("Insert mode: ", time)
  84.             mode = read()
  85.             if mode == "auto" then
  86.                 PasswordConfirmedAuto()
  87.                 break
  88.             elseif mode == "manual" then
  89.                 PasswordConfirmedManual()
  90.                 break
  91.             end
  92.         end
  93.         break
  94.     else
  95.         i = 1
  96.     end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement