Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Computer Light Switch
- local side = "left" -- Set the side for the redstone output
- local userinput = "" -- Initialize user input
- local event = "" -- Initialize event
- redstone.setOutput(side, false) -- Clear output, just in case.
- while true do
- -- First part of the loop, lamp is off.
- term.clear() -- clear the screen
- term.setCursorPos(1,1) -- Put the cursor at the top left corner.
- print("To turn lamp on, press L.")
- print("To exit, press any other key.")
- -- Wait for user input (as a character), convert it to uppercase.
- event, userinput = os.pullEvent("char")
- userinput = string.upper(userinput)
- -- Check to see if the input is an L, otherwise, break the loop.
- if userinput == "L" then
- redstone.setOutput(side, true) -- Turn on the redstone output
- else
- term.clear()
- break
- end
- term.clear() -- clear the screen
- term.setCursorPos(1,1) -- Put the cursor at the top left corner
- print("To turn lamp off, press L.")
- print("To exit, press any other key.")
- -- Wait for user input (as a character), convert it to uppercase.
- event, userinput = os.pullEvent("char")
- userinput = string.upper(userinput)
- -- Check to see if the input is an L, otherwise, break the loop.
- if userinput == "L" then
- redstone.setOutput(side, false) -- Turn off the redstone output
- else
- term.clear()
- break
- end
- end -- End of while true loop.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement