Advertisement
Guest User

passwort.lua

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