Advertisement
SemlerPDX

SwitchFuel

Jul 17th, 2016
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. --Fuel Supply Switcher v2
  2. --by SemlerPDX July2016
  3. -- pastebin get JbXXNjrp SwitchFuel
  4.  
  5. local function fset()
  6.   term.clear()
  7.   term.setCursorPos(1,1)
  8. end
  9.  
  10. --checks to see if door to engine room is open
  11. --opens if it is closed
  12. if (rs.getOutput("back"))~=true then
  13.   rs.setOutput("back",true)
  14. end
  15.  
  16. fset()
  17. textutils.slowPrint("Switching fuel supply from charcoal to coal...", 18)
  18. rs.setOutput("top",true)
  19. sleep(1.75)
  20. fset()
  21. print("Engines are set to burn Coal")
  22. print("")
  23. print("note:")
  24. print("Coal is more abundant but not infinite")
  25. print("Charcoal is infinite but not abundant or efficient")
  26. print("")
  27. print("")
  28. print("  -  press any key to switch back to Charcoal  -")
  29.  
  30.  
  31. -- Main Loop --
  32. while true do
  33.  
  34.   local function fcancel()
  35.     local event, key = os.pullEvent("key")
  36.   end
  37.  
  38.   local function fmain()
  39.     sleep(1)
  40.   end
  41.  
  42.   FunctionEnabled = parallel.waitForAny(fcancel,fmain)
  43.  
  44.   if FunctionEnabled == 1 then
  45.     rs.setOutput("top",false)
  46.     fset()
  47.     textutils.slowPrint("Switching fuel supply from coal to charcoal...", 18)
  48.     sleep(2)
  49.     fset()
  50.     print("Engines are now burning Charcoal")
  51.     sleep(1)
  52.     break
  53.   end
  54. end
  55.  
  56.  
  57. -- Door Close Countdown
  58. for n=1,20 do
  59.  
  60.   local function fcancel()
  61.     local event, key = os.pullEvent("key")
  62.   end
  63.  
  64.   local function fmain()
  65.     fset()
  66.     print("Engines are now burning Charcoal")
  67.     print("")
  68.     print("")
  69.     print("Closing Door in 5 seconds...")
  70.     print("")
  71.     print("  -  press any key to keep Door Open  -")
  72.     sleep(0.25)
  73.   end
  74.  
  75.   FunctionEnabled = parallel.waitForAny(fcancel,fmain)
  76.  
  77.   if FunctionEnabled == 1 then
  78.     fset()
  79.     sleep(1)
  80.     break
  81.   end
  82. end
  83.  
  84. if FunctionEnabled == 2 then
  85.   rs.setOutput("back",false)
  86.   fset()
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement