Advertisement
feedmecookies

Keypad

Apr 6th, 2021 (edited)
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. os.loadAPI("button")
  2. rs.setOutput("bottom",false)
  3. password = "" -- this is the code you will have the keypad have --
  4. code = "" --what is currently in the code
  5. delay = 5 -- the time that the redstone is turned on for --
  6. output = "bottom" -- side it will turn
  7. maxnumb = 4
  8.  
  9. function k1()
  10. code = code.."1"
  11. end
  12.  
  13. function k2()
  14. code = code.."2"
  15. end
  16.  
  17. function k3()
  18. code = code.."3"
  19. end
  20.  
  21. function k4()
  22. code = code.."4"
  23. end
  24.  
  25. function k5()
  26. code = code.."5"
  27. end
  28.  
  29. function k6()
  30. code = code.."6"
  31. end
  32.  
  33. function k7()
  34. code = code.."7"
  35. end
  36.  
  37. function k8()
  38. code = code.."8"
  39. end
  40.  
  41. function k9()
  42. code = code.."9"
  43. end
  44.  
  45.  
  46.  
  47. button.CreateButton(1,2,2,1,1,1,k1,colors.green,"none","")
  48. button.CreateButton(2,4,4,1,1,1,k2,colors.red,"none","")
  49. button.CreateButton(3,6,6,1,1,1,k3,colors.yellow,"none","")
  50. button.CreateButton(4,2,2,3,3,1,k4,colors.pink,"none","")
  51. button.CreateButton(5,4,4,3,3,1,k5,colors.cyan,"none","")
  52. button.CreateButton(6,6,6,3,3,1,k6,colors.lime,"none","")
  53. button.CreateButton(7,2,2,5,5,1,k7,colors.orange,"none","")
  54. button.CreateButton(8,4,4,5,5,1,k8,colors.blue,"none","")
  55. button.CreateButton(9,6,6,5,5,1,k9,colors.magenta,"none","")
  56.  
  57. while true do
  58. if code == password then
  59. button.ClearScreen()
  60. rs.setOutput(output, true)
  61. sleep(delay)
  62. rs.setOutput(output,false)
  63. code = ""
  64. elseif string.len(code) > 4 then
  65. button.ClearScreen()
  66. button.m.setCursorPos(1,1)
  67. button.m.write("Wrong")
  68. button.m.setCursorPos(1,2)
  69. button.m.write("Code!")
  70. sleep(2)
  71. code = ""
  72. end
  73. button.DrawButton()
  74. button.CheckButtons()
  75. end
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement