ilyatop

Keypad

Jan 25th, 2022 (edited)
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. --Перекодил gagaf
  2. --Источник https://oc.cil.li/topic/1008-opensecurity-making-keypad-lock/
  3. local accessCode = "0106" -- код доступа
  4.  
  5. local component = require("component")
  6. local gpu = component.gpu
  7. local event = require("event")
  8. local ser = require("serialization")
  9. local term = require("term")
  10. local computer = component.computer
  11. local door = component.os_doorcontroller -- Тут поменял component.os_door на component.os_doorcontroller
  12. keypad = component.keyboard
  13.  
  14. customButtons = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "⌫", "0", "Ок"}
  15. customButtonColor = {"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"}
  16. keypad.setKey(customButtons, customButtonColor)
  17.  
  18. term.clear()
  19. print("Хрень китайская")
  20. print("---------------------------------------------------------------------------")
  21.  
  22. local inputStr = ""
  23. while true do
  24.   ev, address, button, button_label = event.pull("keypad")
  25.   if ev then
  26.     if button_label == "ok" then
  27.       if inputStr == accessCode then
  28.     term.write("Добро пожаловать в наш сладкийцй мир!\n")
  29.     inputStr = "Привет"
  30.     keypad.setDisplay(inputStr)
  31.     door.toggle()
  32.     os.sleep(2)
  33.     door.toggle()
  34.       else
  35.     term.write("Там гетро сексуал или трансгендер\n")
  36.     inputStr = "Хуй тебе"
  37.     keypad.setDisplay(inputStr)
  38.     computer.beep()
  39.     os.sleep(2)
  40.       end
  41.       inputStr = ""
  42.     elseif button_label == "<" then
  43.       if string.len(inputStr) > 0 then
  44.     tmpStr = string.sub(inputStr, 1 , string.len(inputStr) -1)
  45.     inputStr = tmpStr
  46.       end
  47.     else
  48.       inputStr = inputStr .. button_label
  49.     end
  50.     keypad.setDisplay(inputStr)
  51.   end
  52.   os.sleep(0)
  53. end
  54.  
Add Comment
Please, Sign In to add comment