VintageRice

[CC][Unfinished] - Coord Password Idea

Dec 8th, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. --[[
  2.     Unique password concept
  3.     Idea and created by VintageRIce
  4.     Started: July 26th 2014
  5. ]]
  6.  
  7. --Setting up the variables
  8. local xPass = {"1", "2", "3", "4"}
  9. local yPass = {"1", "2", "3", "4"}
  10. local passChars = {"A", "B", "C", "D"}
  11.  
  12. local xLoc = {0, 0, 0, 0}
  13. local yLoc = {0, 0, 0, 0}
  14.  
  15. local xPos = 1
  16. local yPos = 1
  17.  
  18. local doCount = 1
  19. local passCount = 0
  20.  
  21. --Check if the password is correct
  22. function checkPass()
  23.     for i = 1, 4 do
  24.         if xLoc[i] == xPass[i] then
  25.             passCount = passCount + 1
  26.         end
  27.        
  28.         if yLoc[i] == yPass[i] then
  29.             passCount = passCount + 1
  30.         end
  31.     end
  32.    
  33.     term.clear()
  34.     term.setCursorPos(1, 1)
  35.     print(passCount)
  36. end
  37.  
  38. --Prints the GUI on each key press
  39. function printScreen(value)
  40.     term.clear()
  41.    
  42.     for i = 1, 51 do
  43.         paintutils.drawPixel(i, 16, colours.red)
  44.     end
  45.  
  46.     term.setCursorPos(1, 17)
  47.     print("Editing: "..passChars[doCount])
  48.     print("Current Position: "..xPos..", "..yPos)
  49.  
  50.     term.setCursorPos(xPos, yPos)
  51.     print("X")
  52. end
  53.  
  54. --Monitors the key input
  55. function monitorInput()
  56.     while true do
  57.         event, char = os.pullEvent("char")
  58.  
  59.         if char == "w" or "a" or "s" or "d" or "f" then
  60.             if char == "w" then
  61.                 yPos = yPos - 1
  62.             end
  63.  
  64.             if char == "a" then
  65.                 xPos = xPos - 1    
  66.             end
  67.  
  68.             if char == "s" then
  69.                 yPos = yPos + 1
  70.             end
  71.  
  72.             if char == "d" then
  73.                 xPos = xPos + 1
  74.             end
  75.  
  76.             if char == "f" then
  77.                 for i = 1, 4 do
  78.                     if doCount == i then
  79.                         xLoc[i] = xPos
  80.                         yLoc[i] = yPos
  81.                     end
  82.                 end    
  83.                
  84.                 doCount = doCount + 1
  85.             end
  86.  
  87.             printScreen(doCount)
  88.         end
  89.     end
  90. end
  91.  
  92. printScreen()
  93. monitorInput()
Advertisement
Add Comment
Please, Sign In to add comment