Advertisement
Lobakus

Double Monitor KeyCode

Aug 20th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.03 KB | None | 0 0
  1. --      ###### Please Change only this four things! ######
  2. -- 
  3. --  Build the computer on the side (back) and download the programm as startup, then write startup it should start
  4. --
  5. Passwort (4 times long)
  6. passwort = "1529"
  7. --
  8. -- Redstone output (bottom,top,back,front,left,right)
  9. redout = "bottom"
  10. --
  11. -- Monitor side (bottom,top,back,front,left,right)          ##the side is very important##
  12. moniside = "back"
  13. --
  14. -- Super Admin pass: need to close programm
  15. adminpass = "1423"
  16. --
  17. -- Tastenfarbe:
  18. tastencol = 0x2000
  19. -- Farbcodes:
  20. -- white                                0x1
  21. -- orange                               0x2
  22. -- magenta                              0x4    
  23. -- lightBlue                    0x8    
  24. -- yellow                               0x10  
  25. -- lime                                 0x20
  26. -- pink                                 0x40
  27. -- gray                                 0x80
  28. -- lightGray                    0x100  
  29. -- cyan                                 0x200    
  30. -- purple                               0x400
  31. -- blue                                 0x800  
  32. -- brown                                0x1000
  33. -- green                                0x2000
  34. -- red                                  0x4000
  35. -- black                                0x8000
  36.  
  37. --
  38. -- ### Do not change something down here  ###
  39.  
  40. count = 0
  41. a = 0
  42. b = 0
  43. c = 0
  44. d = 0
  45. eingabe = 0
  46. zugang = 0
  47. term = peripheral.wrap(moniside)
  48. local pullEvent = os.pullEvent
  49. os.pullEvent = os.pullEventRaw
  50. term.setBackgroundColor(colors.black)
  51. if os.getComputerLabel() == nil then
  52. os.setComputerLabel("Passwort-Door" )
  53. end
  54.  
  55. function Rahmen()
  56. term.clear()
  57. term.setTextColor(colors.white)
  58. term.setCursorPos(2,1)
  59. term.setBackgroundColor(tastencol)
  60. term.write(" 1 ")
  61. term.setBackgroundColor(colors.black)
  62. term.write (" ")
  63. term.setBackgroundColor(tastencol)
  64. term.write(" 2 ")
  65. term.setBackgroundColor(colors.black)
  66. term.write (" ")
  67. term.setBackgroundColor(tastencol)
  68. term.write(" 3 ")
  69. term.setBackgroundColor(colors.black)
  70. term.setCursorPos(2,3)
  71. term.setBackgroundColor(tastencol)
  72. term.write(" 4 ")
  73. term.setBackgroundColor(colors.black)
  74. term.write (" ")
  75. term.setBackgroundColor(tastencol)
  76. term.write(" 5 ")
  77. term.setBackgroundColor(colors.black)
  78. term.write (" ")
  79. term.setBackgroundColor(tastencol)
  80. term.write(" 6 ")
  81. term.setBackgroundColor(colors.black)
  82. term.write ("  ")
  83. term.setBackgroundColor(tastencol)
  84. term.write(" C ")
  85. term.setBackgroundColor(colors.black)
  86. term.setCursorPos(2,5)
  87. term.setBackgroundColor(tastencol)
  88. term.write(" 7 ")
  89. term.setBackgroundColor(colors.black)
  90. term.write (" ")
  91. term.setBackgroundColor(tastencol)
  92. term.write(" 8 ")
  93. term.setBackgroundColor(colors.black)
  94. term.write (" ")
  95. term.setBackgroundColor(tastencol)
  96. term.write(" 9 ")
  97. term.setBackgroundColor(colors.black)
  98. term.setCursorPos(15,2)
  99. term.setBackgroundColor(tastencol)
  100. term.write("   ")
  101. term.setCursorPos(15,4)
  102. term.write("   ")
  103. term.setBackgroundColor(colors.black)
  104. end
  105.  
  106.  
  107. function Eingabe()
  108. while count < 4 do
  109. event,side,x,y = os.pullEvent()
  110.  if event == "terminate" then
  111.  write("Admin Passwort:")
  112.  admin = read("*")
  113.  if admin == adminpass then
  114.  os.pullEvent = pullEvent
  115.  write("Right! Now push STRG (or CTRL) + T for 4 seconds. You have 6 seconds.")
  116.  sleep(6)
  117.  end
  118.  end
  119.  if event == "monitor_touch" then
  120.  
  121.   if (x >= 2 and x<= 4) and y == 1 then
  122.    count = count + 1
  123.    if count == 1 then
  124.    a = 1
  125.    term.setBackgroundColor(colors.black)
  126.    punkt()
  127.    elseif count == 2 then
  128.    b = 1
  129.    punkt()
  130.    elseif count == 3 then
  131.    c = 1
  132.    punkt()
  133.    elseif count == 4 then
  134.    d = 1
  135.    punkt()
  136.    end
  137.   end
  138.  
  139.   if (x >= 6 and x<= 8) and y == 1 then
  140.    count = count + 1
  141.    if count == 1 then
  142.    a = 2
  143.    term.setBackgroundColor(colors.black)
  144.    punkt()
  145.    elseif count == 2 then
  146.    b = 2
  147.    punkt()
  148.    elseif count == 3 then
  149.    c = 2
  150.    punkt()
  151.    elseif count == 4 then
  152.    d = 2
  153.    punkt()
  154.    end
  155.   end
  156.  
  157.   if (x >= 10 and x<= 12) and y == 1 then
  158.    count = count + 1
  159.    if count == 1 then
  160.    a = 3
  161.    term.setBackgroundColor(colors.black)
  162.    punkt()
  163.    elseif count == 2 then
  164.    b = 3
  165.    punkt()
  166.    elseif count == 3 then
  167.    c = 3
  168.    punkt()
  169.    elseif count == 4 then
  170.    d = 3
  171.    punkt()
  172.    end
  173.   end
  174.  
  175.   if (x >= 2 and x<= 4) and y == 3 then
  176.    count = count + 1
  177.    if count == 1 then
  178.    a = 4
  179.    term.setBackgroundColor(colors.black)
  180.    punkt()
  181.    elseif count == 2 then
  182.    b = 4
  183.    punkt()
  184.    elseif count == 3 then
  185.    c = 4
  186.    punkt()
  187.    elseif count == 4 then
  188.    d = 4
  189.    punkt()
  190.    end
  191.   end
  192.  
  193.   if (x >= 6 and x<= 8) and y == 3 then
  194.    count = count + 1
  195.    if count == 1 then
  196.    a = 5
  197.    term.setBackgroundColor(colors.black)
  198.    punkt()
  199.    elseif count == 2 then
  200.    b = 5
  201.    punkt()
  202.    elseif count == 3 then
  203.    c = 5
  204.    punkt()
  205.    elseif count == 4 then
  206.    d = 5
  207.    punkt()
  208.    end
  209.   end
  210.  
  211.   if (x >= 10 and x<= 12) and y == 3 then
  212.    count = count + 1
  213.    if count == 1 then
  214.    a = 6
  215.    term.setBackgroundColor(colors.black)
  216.    punkt()
  217.    elseif count == 2 then
  218.    b = 6
  219.    punkt()
  220.    elseif count == 3 then
  221.    c = 6
  222.    punkt()
  223.    elseif count == 4 then
  224.    d = 6
  225.    punkt()
  226.    end
  227.   end
  228.  
  229.   if (x >= 2 and x<= 4) and y == 5 then
  230.    count = count + 1
  231.    if count == 1 then
  232.    a = 7
  233.    term.setBackgroundColor(colors.black)
  234.    punkt()
  235.    elseif count == 2 then
  236.    b = 7
  237.    punkt()
  238.    elseif count == 3 then
  239.    c = 7
  240.    punkt()
  241.    elseif count == 4 then
  242.    d = 7
  243.    punkt()
  244.    end
  245.   end
  246.  
  247.   if (x >= 6 and x<= 8) and y == 5 then
  248.    count = count + 1
  249.    if count == 1 then
  250.    a = 8
  251.    term.setBackgroundColor(colors.black)
  252.    punkt()
  253.    elseif count == 2 then
  254.    b = 8
  255.    punkt()
  256.    elseif count == 3 then
  257.    c = 8
  258.    punkt()
  259.    elseif count == 4 then
  260.    d = 8
  261.    punkt()
  262.    end
  263.   end
  264.  
  265.   if (x >= 10 and x<= 12) and y == 5 then
  266.    count = count + 1
  267.    if count == 1 then
  268.    a = 9
  269.    term.setBackgroundColor(colors.black)
  270.    punkt()
  271.    elseif count == 2 then
  272.    b = 9
  273.    punkt()
  274.    elseif count == 3 then
  275.    c = 9
  276.    punkt()
  277.    elseif count == 4 then
  278.    d = 9
  279.    punkt()
  280.    end
  281.   end
  282.   if (x >= 15 and x<= 17) and (y >= 2 and y<= 5) then
  283.   term.setCursorPos(15,5)
  284.   term.write("    ")
  285.   count = 0
  286.   end
  287.  end
  288. end
  289. count = 0
  290. end
  291.  
  292. function punkt()
  293. if count == 1 then
  294. term.setCursorPos(15,5)
  295. term.write ("*")
  296. elseif count == 2 then
  297. term.setCursorPos(16,5)
  298. term.write ("*")
  299. elseif count == 3 then
  300. term.setCursorPos(17,5)
  301. term.write ("*")
  302. elseif count == 4 then
  303. term.setCursorPos(18,5)
  304. term.write ("*")
  305. sleep(0.1)
  306. end
  307. end
  308.  
  309. function rand()
  310. term.setBackgroundColor(farbe)
  311. term.setCursorPos(1,1)
  312. term.write("                  ")
  313. term.setCursorPos(1,2)
  314. term.write(" ")
  315. term.setCursorPos(18,2)
  316. term.write(" ")
  317. term.setBackgroundColor(colors.black)
  318. term.write(" ")
  319. term.setBackgroundColor(farbe)
  320. term.setCursorPos(1,3)
  321. term.write(" ")
  322. term.setCursorPos(18,3)
  323. term.write(" ")
  324. term.setBackgroundColor(colors.black)
  325. term.write(" ")
  326. term.setBackgroundColor(farbe)
  327. term.setCursorPos(1,4)
  328. term.write(" ")
  329. term.setCursorPos(18,4)
  330. term.write(" ")
  331. term.setBackgroundColor(colors.black)
  332. term.write(" ")
  333. term.setBackgroundColor(farbe)
  334. term.setCursorPos(1,5)
  335. term.write("                  ")
  336. term.setBackgroundColor(colors.black)
  337. end
  338.  
  339.  
  340. while true do
  341. Rahmen()
  342. Eingabe()
  343. eingabe = (""..a..""..b..""..c..""..d.."")
  344. zugang = (passwort-eingabe)
  345. if passwort == eingabe then
  346. term.clear()
  347. term.setBackgroundColor(colors.black)
  348. term.setTextColor(tastencol)
  349. farbe = 8192
  350. rand()
  351. term.setCursorPos(9,3)
  352. term.write ("OK")
  353. rs.setOutput(redout, true)
  354. sleep(2.5)
  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