Aadvert

as

Feb 11th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. local bBreak = false
  2. local chars = {}
  3. local renderTimer;
  4. local isImportant = {["1"] = true, ["2"] = true, ["3"] = true, ["4"] = true, ["5"] = true, ["6"] = true, ["7"] = true, ["8"] = true, ["9"] = true, ["0"] = true}
  5.  
  6. function render()
  7.     term.clear()
  8.     term.setCursorPos(15, 2)
  9.     term.write("PIN #:")
  10.     term.setCursorPos(18, 3)
  11.     term.write("[" .. (chars[1] or "-") .. "]")
  12.     term.setCursorPos(22, 3)
  13.     term.write("[" .. (chars[2] or "-") .. "]")
  14.     term.setCursorPos(26, 3)
  15.     term.write("[" .. (chars[3] or "-") .. "]")
  16.     term.setCursorPos(30, 3)
  17.     term.write("[" .. (chars[4] or "-") .. "]")
  18. end
  19.  
  20. function main()
  21.     renderTimer = os.startTimer(0) -- Initiate rendering
  22.     while true do
  23.         if bBreak then break end
  24.         local evt, p1, p2 = os.pullEvent()
  25.        
  26.         if evt == "timer" and p1 == renderTimer then
  27.             renderTimer = os.startTimer(0.1)
  28.             render()
  29.         elseif evt == "char" then
  30.             if isImportant[p1] then
  31.                 table.insert(chars, p1)
  32.                 -- too lazy to check for overflow
  33.             elseif p1 == "x" then
  34.                 bBreak = true
  35.             end
  36.         end
  37.     end
  38. end
  39. main()
  40.  
  41. term.clear()
  42. term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment