Advertisement
Guest User

startup

a guest
Apr 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.57 KB | None | 0 0
  1. mon = peripheral.wrap("top")
  2. term.redirect(mon)
  3. if fs.exists("bg") then
  4.   print("Loading Background...")
  5. else
  6.   print("Downloading Background...")
  7.   shell.run("pastebin get ZTPGu6zq bg")
  8.   print("Loading Background Image")
  9.   sleep(3)
  10. end
  11. bg = paintutils.loadImage("bg")
  12.  
  13. function drawBG()
  14.   term.clear()
  15.   term.setCursorPos(1,1)
  16.   paintutils.drawImage(bg,1,1)
  17. end
  18.  
  19. function fillIn()
  20.   xH = 1
  21.   mon.setCursorPos(1,xH)
  22.   for i = 1,3 do
  23.     for i = 1,2 do
  24.       mon.setBackgroundColor(colors.white)
  25.       repeat
  26.         xC,yC = mon.getCursorPos()
  27.         mon.write(" ")
  28.       until xC == 6
  29.       mon.setCursorPos(12,xH)
  30.     end
  31.     xH = xH+1
  32.     mon.setCursorPos(1,xH)
  33.   end
  34. end
  35.  
  36. function getDigit()
  37.   if x == 4 and y == 4 then return 1
  38.   elseif x == 7 and y == 4 then return 2
  39.   elseif x == 11 and y == 4 then return 3
  40.   elseif x == 4 and y == 6 then return 4
  41.   elseif x == 7 and y == 6 then return 5
  42.   elseif x == 11 and y == 6 then return 6
  43.   elseif x == 4 and y == 7 then return 7
  44.   elseif x == 7 and y == 7 then return 8
  45.   elseif x == 11 and y == 7 then return 9
  46.   elseif x == 7 and y == 9 then return 0
  47.   end
  48. end
  49.  
  50. function number()
  51.   if y >= 1 and y <= 3 then
  52.   --
  53.     if x >= 1 and x <= 6 then
  54.       return 1
  55.     elseif x >= 7 and x <= 12 then
  56.       return 2
  57.     elseif x >= 13 and x <= 17 then
  58.       return 3
  59.     end
  60.     -- 1-2-3 ^
  61.   elseif y >= 4 and y <= 6 then
  62.   --
  63.     if x >= 1 and x <= 6 then
  64.       return 4
  65.     elseif x >= 7 and x <= 12 then
  66.       return 5
  67.     elseif x >=13 and x <= 17 then
  68.       return 6
  69.     end
  70.   elseif y >= 7 and y <= 9 then
  71.   -- 4-5-6 ^
  72.     if x >= 1 and x <= 6 then
  73.       return 7
  74.     elseif x >= 7 and x <= 12 then
  75.       return 8
  76.     elseif x >= 13 and x <=17 then
  77.       return 9
  78.   -- 7-8-9 ^
  79.     end
  80.   elseif y >= 10 then return 0
  81.   end
  82. end
  83.  
  84. function draw()
  85.   mon.setBackgroundColor(colors.white)
  86.   mon.setTextColor(colors.black)
  87.   mon.setTextScale(0.9)
  88.   mon.clear()
  89.   mon.setCursorPos(4,3)
  90.   mon.write("[1][2][3]")
  91.   mon.setCursorPos(4,5)
  92.   mon.write("[4][5][6]")
  93.   mon.setCursorPos(4,7)
  94.   mon.write("[7][8][9]")
  95.   mon.setCursorPos(4,9)
  96.   mon.write("   [0]")
  97. end
  98. function auth()
  99.   input = {}
  100.   for i = 1,4 do
  101.     event,side,x,y = os.pullEvent("monitor_touch")
  102.     table.insert(input,tonumber(number()))
  103.   end
  104.   result = tonumber(table.concat(input))
  105. end
  106.  
  107. while true do
  108.   drawBG()
  109.   auth()
  110.   if result == 4002 then
  111.     print("Correct!")
  112.     rs.setOutput("bottom",true)
  113.     sleep(2)
  114.     rs.setOutput("bottom",false)
  115.   else
  116.     print(result.." is incorrect!")
  117.   end
  118.   sleep(2)
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement