MrHeavyman

buttonProgram

Jun 14th, 2021 (edited)
448
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. buttonState = 0;
  2.  
  3.  
  4.  
  5. while true do
  6.    
  7.     os.pullEvent("redstone") -- wait for a "redstone" event
  8.         if rs.getInput("front") then -- check the input
  9.     buttonState = buttonState + 1
  10.         end
  11.    
  12.     if (buttonState == 1) then
  13.    
  14.     redstone.setOutput("right", true)
  15.     redstone.setOutput("back", false)
  16.     redstone.setOutput("left", false)
  17.         print("State 1")
  18.  
  19.     end
  20.    
  21.     if (buttonState == 2) then
  22.    
  23.     redstone.setOutput("right", true)
  24.     redstone.setOutput("back", true)
  25.     redstone.setOutput("left", false)
  26.         print("State 2")
  27.    
  28.     end
  29.    
  30.     if (buttonState == 3) then
  31.  
  32.     redstone.setOutput("right", true)
  33.     redstone.setOutput("back", true)
  34.     redstone.setOutput("left", true)
  35.         print("State 3")
  36.    
  37.     end
  38.    
  39.     if (buttonState == 4) then
  40.         print("State 4")
  41.    
  42.     buttonState = 0
  43.    
  44.     end  
  45.    
  46.     if (buttonState == 0) then
  47.  
  48.     redstone.setOutput("right", false)
  49.     redstone.setOutput("back", false)
  50.     redstone.setOutput("left", false)
  51.    
  52.     print("State 0")
  53.  
  54.    
  55.     end
  56. sleep(1)
  57. end
RAW Paste Data