Advertisement
Guest User

password

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