Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- the table below stores a list of players to allow access to
- -- make sure that all usernames in this list are LOWERCASE!
- local whitelist = {
- ['plazter'] = true,
- ['hybridanden'] = true,
- ['alternatelogic'] = true,
- ['theoriginalbit'] = true,
- ['randomguy123'] = true,
- ['suicidalstdz'] = true,
- }
- -- a file stored on the computer so you can check out activity of people coming and going, make sure you put a disk drive so it can save it out
- local logFile = fs.open('/disk/log', 'w')
- -- the side to output the redstone
- local rsSide = 'bottom'
- -- a log function, this prints to the screen and also writes to the file.
- local function log(msg)
- print(msg)
- logFile.write(msg..'\n')
- logFile.flush()
- end
- -- clear the screen
- term.clear()
- term.setCursorPos(1,1)
- -- start a new log, so you can easily tell when the computer has been restarted or whatever
- log('======== New Log - Day: '..os.day()..' Time: '..textutils.formatTime(os.time())..' ========')
- while true do
- -- wait for the player event
- local event, p1 = os.pullEvent('player')
- -- make the player name lowercase for checking if it exists in the whitelist table
- if whitelist[ p1:lower() ] then
- -- log the player has entered
- log('Player: '..p1..' entered!')
- -- open the door
- rs.setOutput(rsSide, true)
- -- this line and the line below are a termination safe sleep call
- os.startTimer(2)
- os.pullEvent('timer')
- -- close the door
- rs.setOutput(rsSide, false)
- else
- -- log that it was unauthorized and their name
- log('Unauthorized player attempted access: '..p1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment