Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Игра "2 клавиши" by Laine_prikol
- local keyboard = require("keyboard")
- local os = require("os")
- local term = require("term")
- input = io.read
- scores = 0
- way = math.random(1, 2)
- term.clear()
- print("********2 клавиши игра*********")
- print("* вы хотите начать играть? *")
- print("* y/n? *")
- print("*******************************")
- input = io.read()
- if input == "y" then
- print("Цель: Нажимайте [Ctrl] или [Shift] и в зависимости от что вы нажмёте вы либо пройдёте дальше, либо проиграете!")
- -- Проверка shift
- while true do
- os.sleep(0.1)
- if keyboard.isShiftDown() == true then
- os.sleep(0.1)
- if way == 1 then
- scores = scores + 1
- term.clear()
- print("Правильно, Очков: "..scores)
- way = math.random(1, 2)
- end
- if way == 2 then
- print("Вы проиграли! Ваш счёт: "..scores)
- os.exit()
- end
- end
- os.sleep(0.1)
- -- Проверка ctrl
- os.sleep(0.1)
- if keyboard.isControlDown() == true then
- os.sleep(0.1)
- if way == 2 then
- scores = scores + 1
- term.clear()
- print("Правильно, Очков: "..scores)
- way = math.random(1, 2)
- end
- if way == 1 then
- print("Вы проиграли! Ваш счёт: "..scores)
- os.exit()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement