Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1.  
  2.  
  3. local side = "left" -- Set the side for the redstone output
  4. local userinput = "" -- Initialize user input
  5. local event = "" -- Initialize event
  6.  
  7. redstone.setOutput(side, false) -- Clear output, just in case.
  8.  
  9. while true do
  10.  
  11. -- First part of the loop, lamp is off.
  12. term.clear() -- clear the screen
  13. term.setCursorPos(1,1) -- Put the cursor at the top left corner.
  14. print("To turn lamp on, press L.")
  15. print("To exit, press any other key.")
  16.  
  17. -- Wait for user input (as a character), convert it to uppercase.
  18. event, userinput = os.pullEvent("char")
  19. userinput = string.upper(userinput)
  20.  
  21. -- Check to see if the input is an L, otherwise, break the loop.
  22. if userinput == "L" then
  23. redstone.setOutput(side, true) -- Turn on the redstone output
  24. else
  25. term.clear()
  26. break
  27. end
  28.  
  29. term.clear() -- clear the screen
  30. term.setCursorPos(1,1) -- Put the cursor at the top left corner
  31. print("To turn lamp off, press L.")
  32. print("To exit, press any other key.")
  33.  
  34. -- Wait for user input (as a character), convert it to uppercase.
  35. event, userinput = os.pullEvent("char")
  36. userinput = string.upper(userinput)
  37.  
  38. -- Check to see if the input is an L, otherwise, break the loop.
  39. if userinput == "L" then
  40. redstone.setOutput(side, false) -- Turn off the redstone output
  41. else
  42. term.clear()
  43. break
  44. end
  45.  
  46. end -- End of while true loop.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement