avartoon15

generator control

Jul 30th, 2021 (edited)
856
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --syngas
  2. local r0 = peripheral.wrap("redstone_integrator_4")
  3. --rs output
  4. local r1 = peripheral.wrap("redstone_integrator_1")
  5. --coal
  6. local r2 = peripheral.wrap("redstone_integrator_5")
  7. --rs input
  8. local r3 = peripheral.wrap("redstone_integrator_3")
  9.  
  10. --term clear
  11. local function clear()
  12.   if term.isColor and term.isColor() then
  13.     term.setBackgroundColor(colors.black)
  14.     term.setTextColor(colors.orange)
  15.   end
  16.   term.clear()
  17.   term.setCursorPos(1, 1)
  18. end
  19. --*****************************
  20. --coal level
  21. --*****************************
  22. function coal()
  23.   if r2.getAnalogInput("down") <= 1 then
  24.     while r2.getAnalogInput("down") < 12 do
  25.       r1.setOutput("north", false)
  26.       clear()
  27.       print("refual coal")
  28.       sleep(1)
  29.     end
  30.   else
  31.     r1.setOutput("north", true)
  32.   end
  33. end
  34.  
  35. --*****************************
  36. --syngas production
  37. --*****************************
  38. function syngas()
  39.   if r0.getAnalogInput("down") <= 1 then
  40.     while r0.getAnalogInput("down") < 12 do
  41.      coal()
  42.      clear()
  43.      write("Syngas refuel")
  44.     end
  45.   else
  46.      coal()
  47.   end
  48.     if r3.getAnalogInput("north") < 14 then
  49.       clear()
  50.       write("Power generator offline")
  51.     end
  52.   end
  53. end
  54.  
  55. --*****************************
  56. --generator
  57. --*****************************
  58.  
  59. function generator()
  60.   if r3.getAnalogInput("north") > 14 and r2.getAnalogInput("down") > 1 and r0.getAnalogInput("down") > 1 then
  61.     r1.setOutput("north", true)
  62.   else
  63.     r1.setOutput("north", false)
  64.   end
  65. end
  66.  
  67. --*****************************
  68. --program starter
  69. --*****************************
  70. while true do
  71.   generator()
  72.   sleep(1)
  73. end
  74.  
RAW Paste Data