Inumel

login

May 17th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. local function loadTable(names)
  2. open = fs.open(tostring(names),"r")
  3. local nstr = open.readAll()
  4. local newtable = textutils.unserialize(nstr)
  5. return newtable
  6. end
  7. local function loadTablepass(pass)
  8. ps = fs.open(tostring(pass),"r")
  9. local num = ps.readAll()
  10. local newtablepass = textutils.unserialize(num)
  11. return newtablepass
  12. end
  13. local function table_contains(table,element)
  14. for _,value in pairs(table) do
  15. if value == element then
  16. return true
  17. end
  18. end
  19. end
  20. options = {"reserved",
  21. -- "test",
  22. -- "butts"
  23. }
  24.  
  25. local function admin()
  26. term.clear()
  27. term.setCursorPos(1,1)
  28. term.setTextColor(colors.cyan)
  29. print("Welcome "..name.."!")
  30. term.setTextColor(colors.white)
  31. print("Type options for a list of options!")
  32. op = read()
  33.  
  34. if op == "options" then
  35. term.setTextColor(colors.red)
  36. for k,v in pairs(options) do print(v) end
  37. term.setTextColor(colors.white)
  38. print("make a selection")
  39. cp = read()
  40. if table_contains(options,cp) then
  41. if cp == "test" then
  42. print("test")
  43. end
  44. if cp == "butts" then
  45. print("test2")
  46. end
  47.  
  48.  
  49.  
  50.  
  51. end
  52. end
  53. end
  54. names = loadTable("names")
  55. pass = loadTablepass("pass")
  56. print("Please enter a staff ID!")
  57. name = read()
  58. print("Please enter your four digit passcode!")
  59. passs = read()
  60. if name == names[1] then
  61. if passs == pass[1] then
  62. admin()
  63. end
  64. end
  65. if name == names[2] then
  66. if passs == pass[2] then
  67. admin()
  68. end
  69. end
  70. open.close()
  71. ps.close()
Advertisement
Add Comment
Please, Sign In to add comment