Advertisement
Guest User

startup

a guest
Nov 2nd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.03 KB | None | 0 0
  1. term.clear()
  2. local exitEvent = os.pullEvent()
  3. os.pullEvent = os.pullEventRaw
  4. local function getCursorPosm(text)
  5. local x,y = term.getSize()
  6. local x2,y2 = term.getCursorPos()
  7. term.setCursorPos(math.ceil((x/2)-(text:len()/2)), y2)
  8. end
  9. local function writeText(text)
  10. local x,y = term.getSize()
  11. local x2,y2 = term.getCursorPos()
  12. term.setCursorPos(math.ceil((x/2)-(text:len() /2)), y2)
  13. write(text)
  14. end
  15. local function printText(text)
  16. local x,y = term.getSize()
  17. local x2,y2 = term.getCursorPos()
  18. term.setCursorPos(math.ceil((x/2) - (text:len() / 2)), y2)
  19. print(text)
  20. end
  21.  
  22. function password()
  23.  
  24. os.loadAPI("sha1")
  25. term.setCursorPos(0,2)
  26. term.setTextColor(colors.red)
  27. printText("Always check for Empty Strings!")
  28. term.setCursorPos(0,3)
  29. print()
  30. term.setCursorPos(0,4)
  31. getCursorPosm("Login: ********")
  32. term.setTextColor(colors.yellow)
  33. write("Login: ")
  34. local inputL = read()
  35. if(sha1.sha1(inputL) == "1db615c3fbc5a6072fa0285fff81bf643a64660c" or inputL == "Endus322") then
  36. term.setCursorPos(0,5)
  37. getCursorPosm("Password: ********")
  38. write("Password: ")
  39. local inputP = read('*')
  40. if(sha1.sha1(inputP) == "57748b0eceaefc69ee3318df60e0b025d33c8323" or inputP == "EndOS") then
  41. term.setCursorPos(0,6)
  42. term.setTextColor(colors.lime)
  43. printText("Welcome Operator!")
  44. sleep(2)
  45. term.clear()
  46. term.setCursorPos(0,1)
  47. term.setTextColor(colors.lime)
  48. printText("CatOS 1.7")
  49. term.setCursorPos(0,2)
  50. term.setTextColor(colors.yellow)
  51. write("> ")
  52. term.setTextColor(colors.white)
  53. else
  54. term.setCursorPos(0,6)
  55. term.setTextColor(colors.red)
  56. printText("Wrong Password!")
  57. sleep(2)
  58. os.reboot()
  59. end
  60.  
  61.  
  62. else
  63. term.setCursorPos(0,5)
  64. term.setTextColor(colors.red)
  65. printText("Wrong User!")
  66. sleep(2)
  67. os.reboot()
  68. end
  69. end
  70.  
  71.  
  72. function suggestion()
  73.   sugPath = "suggestions/"
  74.   x,y = term.getSize()
  75.   term.setCursorPos(0,2)
  76.   term.setTextColor(colors.red)
  77.   printText("Suggestion Box")
  78.   term.setCursorPos(0,4)
  79.   getCursorPosm("Username: standardname")
  80.   term.setTextColor(colors.yellow)
  81.   write("Username: ")
  82.   term.setTextColor(colors.white)
  83.   local uname = read()
  84.   term.setTextColor(colors.yellow)
  85.   write("Suggestion: ")
  86.   term.setTextColor(colors.white)
  87.   local sug = read()
  88.   if(fs.exists(sugPath..uname..".sug")) then
  89.   local f = fs.open(sugPath..uname..".sug", "a")
  90.   f.writeLine()
  91.   f.write("Suggestion: "..sug)
  92.   f.close()
  93.   else
  94.   local f = fs.open(sugPath..uname..".sug", "w")
  95.   f.write("Username: "..uname)
  96.   f.writeLine()
  97.   f.write("Suggestion: "..sug)
  98.   f.close()
  99.   end
  100.   term.setCursorPos(0,7)
  101.   term.setTextColor(colors.lime)
  102.   printText("Thank you for your Suggestion!")
  103.   sleep(2)
  104.   os.reboot()
  105. end
  106.  
  107. x,y = term.getSize()
  108. term.setTextColor(colors.yellow)
  109. term.setCursorPos(0, y/2-2)
  110. printText("Press P to switch to Login Mode")
  111. term.setCursorPos(0, y/2-1)
  112. printText("Press S to switch to Suggestion Mode")
  113. while true do
  114.  
  115.   local event,key = os.pullEvent("key")
  116.   if(key == keys.p) then
  117.     term.clear()
  118.     password()
  119.     break;
  120.   else if(key == keys.s) then
  121.     term.clear()
  122.     suggestion()    
  123.   end
  124.   end
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement