Advertisement
Guest User

Passwort

a guest
Aug 31st, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.21 KB | None | 0 0
  1. passwort = 3587
  2. count = 0
  3. a = 0
  4. b = 0
  5. c = 0
  6. d = 0
  7. eingabe = 0
  8. zugang = 0
  9. monitor = peripheral.wrap("monitor_0")
  10.  
  11. function Rahmen()
  12. monitor.clear()
  13. monitor.setBackgroundColor(colors.green)
  14. monitor.setCursorPos(3,2)
  15. monitor.write("1")
  16. monitor.setBackgroundColor(colors.red)
  17. monitor.setCursorPos(4,2)
  18. monitor.write("2")
  19. monitor.setBackgroundColor(colors.green)
  20. monitor.setCursorPos(5,2)
  21. monitor.write("3")
  22. monitor.setBackgroundColor(colors.red)
  23. monitor.setCursorPos(3,3)
  24. monitor.write("4")
  25. monitor.setBackgroundColor(colors.green)
  26. monitor.setCursorPos(4,3)
  27. monitor.write("5")
  28. monitor.setBackgroundColor(colors.red)
  29. monitor.setCursorPos(5,3)
  30. monitor.write("6")
  31. monitor.setBackgroundColor(colors.green)
  32. monitor.setCursorPos(3,4)
  33. monitor.write("7")
  34. monitor.setBackgroundColor(colors.red)
  35. monitor.setCursorPos(4,4)
  36. monitor.write("8")
  37. monitor.setBackgroundColor(colors.green)
  38. monitor.setCursorPos(5,4)
  39. monitor.write("9")
  40. end
  41.  
  42. monitor.setBackgroundColor(colors.blue)
  43.  
  44. function Eingabe()
  45. while count < 4 do
  46. event,side,x,y = os.pullEvent()
  47.  if event == "monitor_touch" then
  48.  
  49.   if x == 3 and y == 2 then
  50.    count = count + 1
  51.    if count == 1 then
  52.    a = 1
  53.    monitor.setBackgroundColor(colors.blue)
  54.    write("x")
  55.    elseif count == 2 then
  56.    b = 1
  57.    write("x")
  58.    elseif count == 3 then
  59.    c = 1
  60.    write("x")
  61.    elseif count == 4 then
  62.    d = 1
  63.    write("x")
  64.    end
  65.   end
  66.  
  67.   if x == 4 and y == 2 then
  68.    count = count + 1
  69.    if count == 1 then
  70.    a = 2
  71.    monitor.setBackgroundColor(colors.blue)
  72.    write("x")
  73.    elseif count == 2 then
  74.    b = 2
  75.    write("x")
  76.    elseif count == 3 then
  77.    c = 2
  78.    write("x")
  79.    elseif count == 4 then
  80.    d = 2
  81.    write("x")
  82.    end
  83.   end
  84.  
  85.   if x == 5 and y == 2 then
  86.    count = count + 1
  87.    if count == 1 then
  88.    a = 3
  89.    monitor.setBackgroundColor(colors.blue)
  90.    write("x")
  91.    elseif count == 2 then
  92.    b = 3
  93.    write("x")
  94.    elseif count == 3 then
  95.    c = 3
  96.    write("x")
  97.    elseif count == 4 then
  98.    d = 3
  99.    write("x")
  100.    end
  101.   end
  102.  
  103.   if x == 3 and y == 3 then
  104.    count = count + 1
  105.    if count == 1 then
  106.    a = 4
  107.    monitor.setBackgroundColor(colors.blue)
  108.    write("x")
  109.    elseif count == 2 then
  110.    b = 4
  111.    write("x")
  112.    elseif count == 3 then
  113.    c = 4
  114.    write("x")
  115.    elseif count == 4 then
  116.    d = 4
  117.    write("x")
  118.    end
  119.   end
  120.  
  121.   if x == 4 and y == 3 then
  122.    count = count + 1
  123.    if count == 1 then
  124.    a = 5
  125.    monitor.setBackgroundColor(colors.blue)
  126.    write("x")
  127.    elseif count == 2 then
  128.    b = 5
  129.    write("x")
  130.    elseif count == 3 then
  131.    c = 5
  132.    write("x")
  133.    elseif count == 4 then
  134.    d = 5
  135.    write("x")
  136.    end
  137.   end
  138.  
  139.   if x == 5 and y == 3 then
  140.    count = count + 1
  141.    if count == 1 then
  142.    a = 6
  143.    monitor.setBackgroundColor(colors.blue)
  144.    write("x")
  145.    elseif count == 2 then
  146.    b = 6
  147.    write("x")
  148.    elseif count == 3 then
  149.    c = 6
  150.    write("x")
  151.    elseif count == 4 then
  152.    d = 6
  153.    write("x")
  154.    end
  155.   end
  156.  
  157.   if x == 3 and y == 4 then
  158.    count = count + 1
  159.    if count == 1 then
  160.    a = 7
  161.    monitor.setBackgroundColor(colors.blue)
  162.    write("x")
  163.    elseif count == 2 then
  164.    b = 7
  165.    write("x")
  166.    elseif count == 3 then
  167.    c = 7
  168.    write("x")
  169.    elseif count == 4 then
  170.    d = 7
  171.    write("x")
  172.    end
  173.   end
  174.  
  175.   if x == 4 and y == 4 then
  176.    count = count + 1
  177.    if count == 1 then
  178.    a = 8
  179.    monitor.setBackgroundColor(colors.blue)
  180.    write("x")
  181.    elseif count == 2 then
  182.    b = 8
  183.    write("x")
  184.    elseif count == 3 then
  185.    c = 8
  186.    write("x")
  187.    elseif count == 4 then
  188.    d = 8
  189.    write("x")
  190.    end
  191.   end
  192.  
  193.   if x == 5 and y == 4 then
  194.    count = count + 1
  195.    if count == 1 then
  196.    a = 9
  197.    monitor.setBackgroundColor(colors.blue)
  198.    write("x")
  199.    elseif count == 2 then
  200.    b = 9
  201.    write("x")
  202.    elseif count == 3 then
  203.    c = 9
  204.    write("x")
  205.    elseif count == 4 then
  206.    d = 9
  207.    write("x")
  208.    end
  209.   end
  210.  
  211.  end
  212. end
  213. count = 0
  214. end
  215.  
  216. while true do
  217. Rahmen()
  218. Eingabe()
  219.  
  220. eingabe = (""..a..""..b..""..c..""..d.."")
  221. zugang = (passwort-eingabe)
  222. if zugang == 0 then
  223. monitor.print("OK")
  224. rs.setOutput("top", true)
  225. sleep(3)
  226. rs.setOutput("top", false)
  227. else monitor.write("FALSCH")
  228. end
  229.  
  230. sleep(5)
  231. monitor.setBackgroundColor(colors.blue)
  232. coroutine.yield()
  233. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement