Advertisement
iTheDroid

CC-Touchpad

Feb 21st, 2016 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.56 KB | None | 0 0
  1. --  ###### Touchpad version 1.0 by JUMBONET! ######
  2. --  ### Thanks to Hannez04 for the code reload! ###
  3. --
  4. --
  5. --
  6. -- Put the password here (4 Numbers max)
  7. passwort = "1501"
  8. --
  9. -- Redstone Output: (bottom,top,back,front,left,right)
  10. redout = "bottom"
  11. --
  12. -- Monitor Side: (bottom,top,back,front,left,right)
  13. moniside = "right"
  14. --
  15. -- Admin password: (Root mode)
  16. adminpass = "314250"
  17. --
  18. -- Color of the pad numbers:
  19. tastencol = 0x4000
  20. -- Color codes:
  21. -- white                0x1
  22. -- orange               0x2
  23. -- magenta              0x4
  24. -- lightBlue            0x8
  25. -- yellow               0x10   
  26. -- lime                 0x20
  27. -- pink                 0x40
  28. -- gray                 0x80
  29. -- lightGray            0x100  
  30. -- cyan                 0x200    
  31. -- purple               0x400
  32. -- blue                 0x800  
  33. -- brown                0x1000
  34. -- green                0x2000
  35. -- red                  0x4000
  36. -- black                0x8000
  37.  
  38. count = 0
  39. a = 0
  40. b = 0
  41. c = 0
  42. d = 0
  43. eingabe = 0
  44. zugang = 0
  45. term = peripheral.wrap(moniside)
  46. local pullEvent = os.pullEvent
  47. os.pullEvent = os.pullEventRaw
  48. term.setBackgroundColor(colors.black)
  49. if os.getComputerLabel() == nil then
  50. os.setComputerLabel("PIN Touchpad" )
  51. end
  52.  
  53. function Rahmen()
  54. term.clear()
  55. term.setTextColor(colors.white)
  56. term.setCursorPos(2,1)
  57. term.setBackgroundColor(tastencol)
  58. term.write(" 1 ")
  59. term.setBackgroundColor(colors.black)
  60. term.write (" ")
  61. term.setBackgroundColor(tastencol)
  62. term.write(" 2 ")
  63. term.setBackgroundColor(colors.black)
  64. term.write (" ")
  65. term.setBackgroundColor(tastencol)
  66. term.write(" 3 ")
  67. term.setBackgroundColor(colors.black)
  68. term.setCursorPos(2,3)
  69. term.setBackgroundColor(tastencol)
  70. term.write(" 4 ")
  71. term.setBackgroundColor(colors.black)
  72. term.write (" ")
  73. term.setBackgroundColor(tastencol)
  74. term.write(" 5 ")
  75. term.setBackgroundColor(colors.black)
  76. term.write (" ")
  77. term.setBackgroundColor(tastencol)
  78. term.write(" 6 ")
  79. term.setBackgroundColor(colors.black)
  80. term.write ("  ")
  81. term.setBackgroundColor(tastencol)
  82. term.write(" C ")
  83. term.setBackgroundColor(colors.black)
  84. term.setCursorPos(2,5)
  85. term.setBackgroundColor(tastencol)
  86. term.write(" 7 ")
  87. term.setBackgroundColor(colors.black)
  88. term.write (" ")
  89. term.setBackgroundColor(tastencol)
  90. term.write(" 8 ")
  91. term.setBackgroundColor(colors.black)
  92. term.write (" ")
  93. term.setBackgroundColor(tastencol)
  94. term.write(" 9 ")
  95. term.setBackgroundColor(colors.black)
  96. term.setCursorPos(15,2)
  97. term.setBackgroundColor(tastencol)
  98. term.write("   ")
  99. term.setCursorPos(15,4)
  100. term.write("   ")
  101. term.setBackgroundColor(colors.black)
  102. end
  103.  
  104.  
  105. function Eingabe()
  106. while count < 4 do
  107. event,side,x,y = os.pullEvent()
  108.  if event == "terminate" then
  109.  write("Admin Password: ")
  110.  admin = read("*")
  111.  if admin == adminpass then
  112.  os.pullEvent = pullEvent
  113.  shell.run("clear")
  114.  shell.run("shell")
  115.  os.reboot()
  116.  sleep(6)
  117.  else
  118.  term.setTextColor(colors.red)
  119.  print("Wrong password, TRY AGAIN!")
  120.  end
  121.  end
  122.  if event == "monitor_touch" then
  123.  
  124.   if (x >= 2 and x<= 4) and y == 1 then
  125.    count = count + 1
  126.    if count == 1 then
  127.    a = 1
  128.    term.setBackgroundColor(colors.black)
  129.    punkt()
  130.    elseif count == 2 then
  131.    b = 1
  132.    punkt()
  133.    elseif count == 3 then
  134.    c = 1
  135.    punkt()
  136.    elseif count == 4 then
  137.    d = 1
  138.    punkt()
  139.    end
  140.   end
  141.  
  142.   if (x >= 6 and x<= 8) and y == 1 then
  143.    count = count + 1/re
  144.    if count == 1 then
  145.    a = 2
  146.    term.setBackgroundColor(colors.black)
  147.    punkt()
  148.    elseif count == 2 then
  149.    b = 2
  150.    punkt()
  151.    elseif count == 3 then
  152.    c = 2
  153.    punkt()
  154.    elseif count == 4 then
  155.    d = 2
  156.    punkt()
  157.    end
  158.   end
  159.  
  160.   if (x >= 10 and x<= 12) and y == 1 then
  161.    count = count + 1
  162.    if count == 1 then
  163.    a = 3
  164.    term.setBackgroundColor(colors.black)
  165.    punkt()
  166.    elseif count == 2 then
  167.    b = 3
  168.    punkt()
  169.    elseif count == 3 then
  170.    c = 3
  171.    punkt()
  172.    elseif count == 4 then
  173.    d = 3
  174.    punkt()
  175.    end
  176.   end
  177.  
  178.   if (x >= 2 and x<= 4) and y == 3 then
  179.    count = count + 1
  180.    if count == 1 then
  181.    a = 4
  182.    term.setBackgroundColor(colors.black)
  183.    punkt()
  184.    elseif count == 2 then
  185.    b = 4
  186.    punkt()
  187.    elseif count == 3 then
  188.    c = 4
  189.    punkt()
  190.    elseif count == 4 then
  191.    d = 4
  192.    punkt()
  193.    end
  194.   end
  195.  
  196.   if (x >= 6 and x<= 8) and y == 3 then
  197.    count = count + 1
  198.    if count == 1 then
  199.    a = 5
  200.    term.setBackgroundColor(colors.black)
  201.    punkt()
  202.    elseif count == 2 then
  203.    b = 5
  204.    punkt()
  205.    elseif count == 3 then
  206.    c = 5
  207.    punkt()
  208.    elseif count == 4 then
  209.    d = 5
  210.    punkt()
  211.    end
  212.   end
  213.  
  214.   if (x >= 10 and x<= 12) and y == 3 then
  215.    count = count + 1
  216.    if count == 1 then
  217.    a = 6
  218.    term.setBackgroundColor(colors.black)
  219.    punkt()
  220.    elseif count == 2 then
  221.    b = 6
  222.    punkt()
  223.    elseif count == 3 then
  224.    c = 6
  225.    punkt()
  226.    elseif count == 4 then
  227.    d = 6
  228.    punkt()
  229.    end
  230.   end
  231.  
  232.   if (x >= 2 and x<= 4) and y == 5 then
  233.    count = count + 1
  234.    if count == 1 then
  235.    a = 7
  236.    term.setBackgroundColor(colors.black)
  237.    punkt()
  238.    elseif count == 2 then
  239.    b = 7
  240.    punkt()
  241.    elseif count == 3 then
  242.    c = 7
  243.    punkt()
  244.    elseif count == 4 then
  245.    d = 7
  246.    punkt()
  247.    end
  248.   end
  249.  
  250.   if (x >= 6 and x<= 8) and y == 5 then
  251.    count = count + 1
  252.    if count == 1 then
  253.    a = 8
  254.    term.setBackgroundColor(colors.black)
  255.    punkt()
  256.    elseif count == 2 then
  257.    b = 8
  258.    punkt()
  259.    elseif count == 3 then
  260.    c = 8
  261.    punkt()
  262.    elseif count == 4 then
  263.    d = 8
  264.    punkt()
  265.    end
  266.   end
  267.  
  268.   if (x >= 10 and x<= 12) and y == 5 then
  269.    count = count + 1
  270.    if count == 1 then
  271.    a = 9
  272.    term.setBackgroundColor(colors.black)
  273.    punkt()
  274.    elseif count == 2 then
  275.    b = 9
  276.    punkt()
  277.    elseif count == 3 then
  278.    c = 9
  279.    punkt()
  280.    elseif count == 4 then
  281.    d = 9
  282.    punkt()
  283.    end
  284.   end
  285.   if (x >= 15 and x<= 17) and (y >= 2 and y<= 5) then
  286.   term.setCursorPos(15,5)
  287.   term.write("    ")
  288.   count = 0
  289.   end
  290.  end
  291. end
  292. count = 0
  293. end
  294.  
  295. function punkt()
  296. if count == 1 then
  297. term.setCursorPos(15,5)
  298. term.write ("*")
  299. elseif count == 2 then
  300. term.setCursorPos(16,5)
  301. term.write ("*")
  302. elseif count == 3 then
  303. term.setCursorPos(17,5)
  304. term.write ("*")
  305. elseif count == 4 then
  306. term.setCursorPos(18,5)
  307. term.write ("*")
  308. sleep(0.1)
  309. end
  310. end
  311.  
  312. function rand()
  313. term.setBackgroundColor(farbe)
  314. term.setCursorPos(1,1)
  315. term.write("                  ")
  316. term.setCursorPos(1,2)
  317. term.write(" ")
  318. term.setCursorPos(18,2)
  319. term.write(" ")
  320. term.setBackgroundColor(colors.black)
  321. term.write(" ")
  322. term.setBackgroundColor(farbe)
  323. term.setCursorPos(1,3)
  324. term.write(" ")
  325. term.setCursorPos(18,3)
  326. term.write(" ")
  327. term.setBackgroundColor(colors.black)
  328. term.write(" ")
  329. term.setBackgroundColor(farbe)
  330. term.setCursorPos(1,4)
  331. term.write(" ")
  332. term.setCursorPos(18,4)
  333. term.write(" ")
  334. term.setBackgroundColor(colors.black)
  335. term.write(" ")
  336. term.setBackgroundColor(farbe)
  337. term.setCursorPos(1,5)
  338. term.write("                  ")
  339. term.setBackgroundColor(colors.black)
  340. end
  341.  
  342.  
  343. while true do
  344. Rahmen()
  345. Eingabe()
  346. eingabe = (""..a..""..b..""..c..""..d.."")
  347. zugang = (passwort-eingabe)
  348. if passwort == eingabe then
  349. term.clear()
  350. term.setBackgroundColor(colors.black)
  351. term.setTextColor(colors.lime)
  352. farbe = 8192
  353. rand()
  354. term.setCursorPos(9,3)
  355. term.write ("YES")
  356. rs.setOutput(redout, true)
  357. sleep(2.5)
  358. rs.setOutput(redout, false)
  359. os.reboot()
  360. else
  361. term.clear()
  362. term.setBackgroundColor(colors.black)
  363. term.setTextColor(colors.red)
  364. farbe = 16384
  365. rand()
  366. term.setCursorPos(8,3)
  367. term.write("WRONG")
  368. sleep (1)
  369. term.setCursorPos(6,3)
  370. term.write("       ")
  371. term.setCursorPos(9,3)
  372. term.write("5")
  373. sleep(1)
  374. term.setCursorPos(9,3)
  375. term.write("4")
  376. sleep(1)
  377. term.setCursorPos(9,3)
  378. term.write("3")
  379. sleep(1)
  380. term.setCursorPos(9,3)
  381. term.write("2")
  382. sleep(1)
  383. term.setCursorPos(9,3)
  384. term.write("1")
  385. sleep(1)
  386. os.reboot()
  387. end
  388. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement