Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.27 KB | None | 0 0
  1. passAttempt = ""
  2. pass = "1111"
  3. function clear()
  4.   term.clear()
  5.   term.setCursorPos(1,1)
  6. end
  7.  
  8. function getClicked()
  9.   if y == 7 then
  10.     if x == 8 then
  11.       clickedNum = 1
  12.     elseif x == 10 then
  13.       clickedNum = 2
  14.     elseif x == 12 then
  15.       clickedNum = 3
  16.     end
  17.   elseif y == 9 then
  18.     if x == 8 then
  19.       clickedNum = 4
  20.     elseif x == 10 then
  21.       clickedNum = 5
  22.     elseif x == 12 then
  23.       clickedNum = 6
  24.     end
  25.   elseif y == 11 then
  26.     if x == 8 then
  27.       clickedNum = 7
  28.     elseif x == 10 then
  29.       clickedNum = 8
  30.     elseif x == 12 then
  31.       clickedNum = 9
  32.     end
  33.   elseif y == 13 then
  34.     if x == 10 then
  35.       clickedNum = 0
  36.     end
  37.   end
  38. end
  39.  
  40. function PINsetup()
  41.  
  42. clear()
  43. x = 3
  44.  
  45. print("SVETprog PIN program V0.1 - LUA, CC")
  46. term.setCursorPos(12,x)
  47. print("Please enter your PIN.")
  48. term.setCursorPos(12,x+2)
  49. print("----------------------")
  50.  
  51. x=8
  52. y=7
  53.  
  54. term.setCursorPos(x,y)
  55. term.setBackgroundColor(colors.white)
  56. term.setTextColor(colors.black)
  57. print(1)
  58. term.setCursorPos(x+2,y)
  59. print(2)
  60. term.setCursorPos(x+4,y)
  61. print(3)
  62. term.setCursorPos(x, y+2)
  63. print(4)
  64. term.setCursorPos(x+2,y+2)
  65. print(5)
  66. term.setCursorPos(x+4,y+2)
  67. print(6)
  68. term.setCursorPos(x, y+4)
  69. print(7)
  70. term.setCursorPos(x+2, y+4)
  71. print(8)
  72. term.setCursorPos(x+4,y+4)
  73. print(9)
  74. term.setCursorPos(x+2, y+6)
  75. print(0)
  76.  
  77. term.setTextColor(colors.white)
  78. term.setBackgroundColor(colors.black)
  79. term.setCursorPos(30,9)
  80. print(">  ")
  81. term.setCursorPos(34,9)
  82. end
  83.  
  84. clickCounter = 0
  85. PINsetup()
  86.  
  87. while true do
  88.   event, x, y = os.pullEvent()
  89.   if event == "click" then
  90.     getClicked()
  91.     if clickedNum ~= nil then
  92.       write("*")
  93.       passAttempt = passAttempt .. tostring(clickedNum)
  94.       clickedNum = nil
  95.       clickCounter = clickCounter + 1
  96.     else
  97.       term.setCursorPos(34,10)
  98.       print("Invalid Click.")
  99.       sleep(1)
  100.       PINsetup()
  101.       term.setCursorPos(34,9)
  102.       asNum = string.len(passAttempt)
  103.       for i = 1,asNum do
  104.         write("*")
  105.       end
  106.     end
  107.   if clickCounter >= 4 then
  108.     PINsetup()
  109.     print("Please Wait")
  110.     break
  111.   end
  112.   end
  113. end
  114.  
  115. sleep(5)    
  116. clear()
  117.  
  118. if passAttempt == pass then
  119.   print("Password Accepted!")
  120. else
  121.   print("Password denied!")
  122. end
  123.  
  124. term.setBackgroundColor(colors.black)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement