Sectly_Playz

Untitled

May 3rd, 2023 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. function centerPrint(text,y)
  2. if y == nil then y = 1 end
  3. local dx, dy = term.getSize()
  4. term.setCursorPos(dx/2-#text/2,y)
  5. print(text)
  6. end
  7.  
  8. local istyping = true
  9. local input = ""
  10. local printoutput = input
  11. local pchar = "x"
  12. local charlimit = 30
  13. local password = "password"
  14.  
  15. function setPrintOutput()
  16. printoutput = input
  17. if #printoutput > charlimit then
  18. printoutput = printoutput:sub(#printoutput-charlimit,#printoutput)
  19. end
  20. if #input > 1 then
  21. printoutput = ""
  22. for i=1 , #input-1 do
  23. printoutput = printoutput.."x"
  24. end
  25. printoutput = printoutput..input:sub(#input,#input)
  26. end
  27. end
  28.  
  29. if term.isColor() then
  30. while istyping do
  31. term.setBackgroundColor(colors.gray)
  32. term.setTextColor(colors.cyan)
  33. term.clear()
  34. term.setCursorPos(1,1)
  35. centerPrint("Login System",8)
  36. centerPrint("-=-=-=-=-=-=-=-=-=-=-=-",9)
  37. setPrintOutput()
  38. term.setTextColor(colors.white)
  39. centerPrint(">"..printoutput.."<",11)
  40. local event, a1 = os.pullEventRaw()
  41. if event == "char" then
  42. local keypressed = a1
  43. input = input..keypressed
  44. elseif event == "key" then
  45. local keycode = a1
  46. if keycode == 14 then
  47. input = input:sub(1,#input-1)
  48. elseif keycode == 28 or input == password:sub(1, -2) then
  49. if input == password:sub(1, -2) then
  50. term.setTextColor(colors.lime)
  51. centerPrint("Access Granted!",13)
  52.  
  53. redstone.setOutput("back", true)
  54.  
  55. sleep(2)
  56.  
  57. redstone.setOutput("back", false)
  58.  
  59. term.setBackgroundColor(colors.black)
  60. term.setTextColor(colors.white)
  61. term.clear()
  62. term.setCursorPos(1,1)
  63.  
  64. sleep(4)
  65.  
  66. os.reboot()
  67. else
  68. term.setTextColor(colors.orange)
  69. centerPrint("Access Denied!",13)
  70. sleep(2)
  71. input = ""
  72. end
  73. end
  74. end
  75. end
  76. else
  77. while istyping do
  78. term.setBackgroundColor(colors.white)
  79. term.setTextColor(colors.black)
  80. term.clear()
  81. term.setCursorPos(1,1)
  82. centerPrint("Login System",8)
  83. centerPrint("-=-=-=-=-=-=-=-=-=-=-=-",9)
  84. setPrintOutput()
  85. centerPrint(">"..printoutput.."<",11)
  86. local event, a1 = os.pullEventRaw()
  87. if event == "char" then
  88. local keypressed = a1
  89. input = input..keypressed
  90. elseif event == "key" then
  91. local keycode = a1
  92. if keycode == 14 then
  93. input = input:sub(1,#input-1)
  94. elseif keycode == 28 or input == password:sub(1, -2) then
  95. if input == password:sub(1, -2) then
  96. centerPrint("Access Granted!",13)
  97.  
  98. redstone.setOutput("back", true)
  99.  
  100. sleep(2)
  101.  
  102. redstone.setOutput("back", false)
  103.  
  104. term.setTextColor(colors.white)
  105. term.setBackgroundColor(colors.black)
  106. term.clear()
  107. term.setCursorPos(1,1)
  108.  
  109. sleep(4)
  110.  
  111. os.reboot()
  112. else
  113. centerPrint("Access Denied!",13)
  114. sleep(2)
  115. input = ""
  116. end
  117. end
  118. end
  119. end
  120. end
Advertisement
Add Comment
Please, Sign In to add comment