Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor = peripheral.find("monitor")
- local rside = "back"
- if not monitor then
- printError("No monitor connected")
- end
- monitor.setTextScale(0.5)
- local w, h = monitor.getSize()
- local function centerPrint(text, y)
- monitor.setCursorPos((w - #text) / 2 + 1, y)
- monitor.write(text)
- end
- local atPos = math.floor(h / 2)
- local itPos = math.floor(h / 2) + 1
- function setActive(active)
- redstone.setOutput(rside, not active)
- monitor.setTextColor(colors.white)
- if active then
- monitor.setBackgroundColor(colors.green)
- monitor.clear()
- centerPrint("Active", atPos)
- else
- monitor.setBackgroundColor(colors.red)
- monitor.clear()
- centerPrint("Inactive", atPos)
- end
- monitor.setTextColor(colors.lightGray)
- centerPrint("Right click", itPos)
- centerPrint("to toggle", itPos + 1)
- end
- local active = false
- setActive(active)
- while true do
- local event, side, x, y = os.pullEvent("monitor_touch")
- active = not active
- setActive(active)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement