Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local _seclevel = 3
- local sides = {"top", "bottom", "left", "right", "front", "back"}
- local _monitor, _drive= "", ""
- local mon = peripheral.wrap("monitor_0")
- local _passwords = {"5BCE0FE268FA6B4B801FB1082F185B90000AB1258202C653F64B4F037D172336", "9EA9B8889DE45FA608597CB52B79749E2E32C97EF6481CFE6B315655933331F8", "387B8E8247FE18FFFA39FA2DFCDFB555633A0585B6F7D781FFCDA8E82AA20232", "51B92A735030BDBF16100656E55D9F98D0CACA269266782E2F3E850894898BEE", "7B48A89633F05F625E007F3287CD3858584503B9972578791D321851C9D44E51"}
- for i=1, #sides do
- if peripheral.isPresent(sides[i]) then
- if peripheral.getType(sides[i]) == "monitor" then
- _monitor = sides[i]
- end
- if peripheral.getType(sides[i]) == "drive" then
- _drive = sides[i]
- end
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- mon.clear()
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.setCursorPos(2,3)
- mon.write("Ready")
- while true do
- event, side = os.pullEvent()
- if event == "disk" then
- local time = os.time()
- local formattedTime = textutils.formatTime(time, false)
- local data
- local check = "blank"
- local passwordMatch = -1
- if fs.exists("disk/password") then
- local file = fs.open("disk/password","r")
- data = file.readLine()
- file.close()
- for i=1, #_passwords do
- if data == _passwords[i] then
- passwordMatch = i
- end
- end
- if passwordMatch == -1 then
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,2)
- mon.write("Access")
- mon.setCursorPos(1,4)
- mon.write("Denied")
- print("- Invalid Password. TIME:" .. formattedTime)
- -- PASSWORD INVALID (DO STUFF HERE)
- elseif passwordMatch < _seclevel then
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,2)
- mon.write("Higher")
- mon.setCursorPos(1,3)
- mon.write("Access")
- mon.setCursorPos(1,4)
- mon.write("Required")
- print("- Low Access. TIME:" .. formattedTime)
- -- NEED HIGHER ACCESS CARD (DO STUFF HERE)
- elseif passwordMatch >= _seclevel then
- mon.setBackgroundColor(colors.green)
- mon.setTextColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,2)
- mon.write("Access")
- mon.setCursorPos(1,4)
- mon.write("Granted")
- print("- Access granted. Level " .. passwordMatch .. " card. TIME:" .. formattedTime)
- -- ACCESS GRANTED (DO STUFF HERE)
- end
- else
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,2)
- mon.write("Invalid")
- mon.setCursorPos(1,3)
- mon.write("Access")
- mon.setCursorPos(1,4)
- mon.write("Card")
- print("- Unformatted Card. TIME:" .. formattedTime)
- -- INVALID ACCESS CARD (DO STUFF HERE)
- end
- peripheral.call(_drive, "ejectDisk")
- os.sleep(4)
- end
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.clear()
- mon.setCursorPos(2,3)
- mon.write("Ready")
- end
Add Comment
Please, Sign In to add comment