Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local oldPull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- local function loadTable(names)
- open = fs.open(tostring(names),"r")
- local nstr = open.readAll()
- local newtable = textutils.unserialize(nstr)
- return newtable
- end
- local function loadTablepass(pass)
- ps = fs.open(tostring(pass),"r")
- local num = ps.readAll()
- local newtablepass = textutils.unserialize(num)
- return newtablepass
- end
- local function table_contains(table,element)
- for _,value in pairs(table) do
- if value == element then
- return true
- end
- end
- end
- options = {"reserved",
- -- "test",
- -- "butts"
- }
- local function fail()
- write("Incorrect username or password ")
- textutils.slowWrite("Shutting down...")
- sleep(1)
- os.reboot()
- end
- local function admin()
- os.pullEvent = oldPull
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.cyan)
- print("Welcome "..name.."!")
- term.setTextColor(colors.white)
- print("Type options for a list of options!")
- op = read()
- if op == "options" then
- term.setTextColor(colors.red)
- for k,v in pairs(options) do print(v) end
- term.setTextColor(colors.white)
- print("make a selection")
- cp = read()
- if table_contains(options,cp) then
- if cp == "test" then
- print("test")
- end
- if cp == "butts" then
- print("test2")
- end
- if cp == "reserved" then
- print("Exiting..")
- sleep(2)
- os.reboot()
- end
- end
- end
- end
- names = loadTable("names")
- pass = loadTablepass("pass")
- term.clear()
- term.setCursorPos(1,1)
- print("Please enter a staff ID!")
- name = read()
- print("Please enter your four digit passcode!")
- passs = read()
- if name == names[1] then
- if passs == pass[1] then
- admin()
- end
- else
- fail()
- end
- if name == names[2] then
- if passs == pass[2] then
- admin()
- end
- else
- fail()
- end
- open.close()
- ps.close()
Advertisement
Add Comment
Please, Sign In to add comment