Wardes

MachineManager

Sep 18th, 2021 (edited)
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. machineSide = {} -- top,back,right,left,bottom,front
  2.  
  3. shell.run("label set MachineManager")
  4. machineState = {}
  5. for key, value in pairs(machineSide) do
  6.     machineState[key] = false
  7. end
  8.  
  9. shell.run("clear")
  10. function startMachine(key, side)
  11.     machineState[key] = true
  12.     redstone.setOutput(side, false)
  13.     term.setTextColor(colors.green)
  14.     term.setCursorPos(1,key)
  15.     print(side .. " On ")
  16.     sleep(10)
  17.     term.setTextColor(colors.red)
  18.     term.setCursorPos(1,key)
  19.     print(side .. " Off")
  20.     machineState[key] = false
  21. end
  22.  
  23. while true do
  24.     for key, value in pairs(machineSide) do
  25.         if machineState[key] == false then
  26.             mPeri = peripheral.wrap(value)
  27.             if #mPeri.list() > 1 then
  28.                 startMachine(key, value)
  29.             else
  30.                 redstone.setOutput(value, true)
  31.                 term.setTextColor(colors.red)
  32.                 term.setCursorPos(1,key)
  33.                 print(value .. " Off")
  34.             end
  35.         end
  36.     end
  37.     sleep(1)
  38. end
Add Comment
Please, Sign In to add comment