Advertisement
CdoubleOK

Refinery Control

Apr 30th, 2023 (edited)
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. function showMenu(modem)
  2.   term.clear()
  3.   term.setCursorPos(1,1)
  4.  
  5. local menuOptions = {
  6.   "Oil Rig",
  7.   "Crude Input",
  8.   "Crude Output",
  9.   "Crude Refine",
  10.   "Light Oil Output",
  11.   "Heavy Oil Output",
  12.   "Bitumen Processing",
  13.   "Light Oil Refine",
  14.   "Heavy Oil Refine",
  15.   "Fuel Output"
  16. }
  17.  
  18.   term.setCursorPos(4,1)
  19.   print("Refinery Control")
  20.   term.setCursorPos(4,2)
  21.   print("-=-=-=-=-=-=-=-")
  22.   term.setCursorPos(1,4)
  23.   print("1. Oil Rig")
  24.   print("2. Crude Input")
  25.   print("3. Crude Output")
  26.   print("4. Crude Refine")
  27.   print("5. Light Oil Output")
  28.   print("6. Heavy Oil Output")
  29.   print("7. Bitumen Processing")
  30.   print("8. Light Oil Refine")
  31.   print("9. Heavy Oil Refine")
  32.   print("10. Fuel Output")
  33.  
  34.   local choice = nil
  35.   repeat
  36.     term.write("Enter your choice (1-10): ")
  37.     choice = tonumber(read())
  38.   until choice and choice >= 1 and choice <= 10
  39.  
  40.   term.clear()
  41.   term.setCursorPos(1,1)
  42.   term.write("Enter On or Off for "..menuOptions[choice]..": ")
  43.    
  44.   local onOff = read()
  45.   local channel = nil
  46.    
  47.   if choice == 1 then
  48.     channel = 23
  49.   end
  50.   if choice >= 2 and choice <= 5 then
  51.     channel = 26
  52.   elseif choice >= 6 and choice <= 10 then
  53.     channel = 27
  54.   end
  55.  
  56.   if channel then
  57.     modem.transmit(channel, choice, onOff)
  58.   end
  59.   return onOff
  60. end
  61.  
  62. local modem = peripheral.find("modem")
  63. local onOffValues = {}
  64.  
  65. while rs.getInput("front") == false
  66. do
  67. showMenu(modem)
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement