FelixPBanan

MagReader

Nov 8th, 2017
178
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Спасибо ECS,Alex,FingerComp и Zer0Galaxy
  2. --By FelixBanan
  3. local com = require("component")
  4. local event = require("event")
  5. local sides = require("sides")
  6. local rs = com.redstone
  7. local gpu = com.gpu
  8. local sW, sH = gpu.getResolution()
  9.  
  10. local pass = select(1, ...)
  11. local side = select(2, ...)
  12.  
  13.  
  14. local function drawDefault()
  15.   gpu.setBackground(0xFFFF00)
  16.   gpu.fill(1,1,24,5," ")
  17.   gpu.setBackground(0xBDBDBD)
  18.   gpu.setForeground(0xFFFF00)
  19.   gpu.set(5,3," Проведите карту. ")
  20. end
  21.  
  22. local function drawGreen()
  23.   gpu.setBackground(0x00FF00)
  24.   gpu.fill(1,1,24,5," ")
  25.   gpu.setBackground(0xBDBDBD)
  26.   gpu.setForeground(0x00FF00)
  27.   gpu.set(5,3," Код карты принят. ")
  28. end
  29.  
  30. local function drawRed()
  31.   gpu.setBackground(0xFF0000)
  32.   gpu.fill(1,1,24,5," ")
  33.   gpu.setBackground(0xBDBDBD)
  34.   gpu.setForeground(0xFF0000)
  35.   gpu.set(4,3," Ошибка кода карты! ")
  36. end
  37.  
  38. local function drawShell()
  39.   gpu.setResolution(sW, sH)
  40.   gpu.setForeground(0xFFFFFF)
  41.   gpu.fill(1,1,sW,sH," ")
  42.   gpu.setBackground(0x1E1E1E)
  43.   gpu.fill(1,1,sW,sH," ")
  44. end
  45.  
  46. if pass and side then
  47. gpu.setResolution(24,5)
  48.   while true do
  49.     drawDefault()
  50.     local output = { event.pull() }
  51.     if output[1] == "magData" then
  52.       if output[4] == pass then
  53.         drawGreen()
  54.         rs.setOutput(sides[side], 15)
  55.         os.sleep(2)
  56.       else
  57.         drawRed()
  58.         os.sleep(2)
  59.       end
  60.       drawDefault()
  61.       rs.setOutput(sides[side], 0)
  62.     elseif output[1] == "key_down" and output[4] == 28 then
  63.       drawShell()
  64.       break
  65.     end
  66.   end
  67. else
  68.   print("Стороны редстоун блока: bottom, top, back, right, left, right")
  69.   print("Использование: Mag <пароль> <сторона для вывода редстоуна>")
  70. end
RAW Paste Data