Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- * configuration
- local usernamesToAccept = {
- "yourUserame",
- "otherUserame",
- "LBPHacker"
- }
- local innerMonitorName = "monitor_0"
- local outerDetectorName = "playerDetector_0"
- local redstoneOutput = "bottom"
- -- * not my style, but wrap up the monitor (I prefer peripheral.call)
- local monitor = peripheral.wrap(innerMonitorName)
- -- * updates the redstone output and the monitor
- local toggleOutput = function()
- local current = not rs.getOutput(redstoneOutput)
- rs.setOutput(redstoneOutput, current) -- * toggles the output
- monitor.setBackgroundColor(current and colors.lime or colors.red)
- monitor.clear()
- monitor.setCursorPos(2, 3)
- monitor.write(current and "MFFS: [ON]| OFF " or "MFFS: ON |[OFF]")
- end
- -- * checks for access
- local hasAccess = function(username)
- local access = false
- for uix = 1, #usernamesToAccept do access = usernamesToAccept[uix] == username or access end -- * gives access sooner or later if the username is in the table 'usernamesToAccept'
- return access
- end
- monitor.setTextColor(colors.white)
- rs.setOutput(redstoneOutput, false) -- * change false to true if you want the MFFS to be off by default
- toggleOutput()
- -- * endless loop
- while true do
- local eventData = {os.pullEvent()} -- * puts the event data into a table
- if eventData[1] == "monitor_touch" or eventData[1] == "player" and hasAccess(eventData[2]) then
- -- * nothing is on the monitor apart from the button
- -- which toggles the MFFS, so no need of fancy button APIs
- toggleOutput()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement