Advertisement
Nielsnederlands

generatorControl

Jul 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1.  
  2. local MFSUinput = false -- MFSU outputs when full
  3. local UserInput = false -- manual control
  4.  
  5. redstone.setOutput("back", false)
  6. while true do
  7.  
  8.     -- read inputs
  9.     if( redstone.getInput("bottom") ) then
  10.         MFSUinput = true
  11.         --print("MFSU input true")
  12.     else
  13.         MFSUinput = false
  14.         --print("MFSU input false")
  15.     end
  16.    
  17.     if( redstone.getInput("right") ) then
  18.         UserInput = true
  19.         --print("Manual input true")
  20.     else
  21.         UserInput = false
  22.         --print("Manual input false")
  23.     end
  24.    
  25.     -- determine output
  26.     if (UserInput) then
  27.         redstone.setOutput("back", false)
  28.     elseif (MFSUinput and not UserInput) then
  29.         redstone.setOutput("back", true)
  30.        
  31.         -- checks for manual interference
  32.         local count = 0
  33.         while (count < 12) do
  34.             sleep(1)
  35.             count = count + 1
  36.            
  37.             if( redstone.getInput("right") ) then
  38.                 UserInput = true
  39.                 print("Manual interference")
  40.                 break
  41.             end
  42.            
  43.         end
  44.        
  45.     else
  46.         redstone.setOutput("back", false)
  47.     end
  48.     sleep(1)
  49.    
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement