Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require("term")
- local io = require("io")
- local thread = require("thread")
- local fs = require("filesystem")
- MestoN1 = "test "
- MestoO1 = 10
- MestoN2 = "Test "
- MestoO2 = 8
- MestoN3 = "teSt "
- MestoO3 = 6
- MestoN4 = "tesT "
- MestoO4 = 4
- MestoN5 = "tEst "
- MestoO5 = 2
- function TRecord()
- term.clear()
- print(' <Таблица рекордов> \n')
- print('Место | Имя | Результат')
- print(' 1. |'..MestoN1.." | "..MestoO1)
- print(' 2. |'..MestoN2.." | "..MestoO2)
- print(' 3. |'..MestoN3.." | "..MestoO3)
- print(' 4. |'..MestoN4.." | "..MestoO4)
- print(' 5. |'..MestoN5.." | "..MestoO5)
- print("Нажмите Enter для выхода в меню")
- io.read()
- term.clear()
- MMenu()
- end
- function Timer()
- os.sleep(1)
- if t ~= 0 then
- t=t-1
- Timer()
- end
- end
- function Game()
- term.clear()
- x = "random"
- t = 5
- thread.init()
- print('Уровень: '..lvl+1)
- --print('Осталось '..t..' секунд')
- print('Наберите: '..x)
- thread.create (Timer)
- local y = io.read()
- thread.killAll()
- if t == 0 then
- term.clear()
- print('Время истекло')
- os.sleep(2)
- POchki()
- elseif x == y then
- print('Поздравляю!\nСледующий уровень')
- lvl = lvl+1
- os.sleep(1)
- Game()
- else
- term.clear()
- print('Увы, вы проиграли на уровне '..lvl+1)
- os.sleep(2)
- POchki()
- end
- end
- function POchki()
- if lvl < MestoO5 then
- MMenu()
- elseif lvl < MestoO4 then
- print('Поздравляю вы заняли 5ое место!')
- print('Введите свой ник:')
- --MestoN5 = io.read(7)
- local file = io.open("games.txt","w")
- --file:seek("set(7,11)")
- file:write(lvl)
- file:close("games.txt")
- MMenu()
- elseif lvl < MestoO3 then
- print('Поздравляю вы заняи 4ое место!')
- print('Введите свой ник:')
- io.read(7)
- MMenu()
- elseif lvl < MestoO2 then
- print('Поздравляю вы заняли 3е место!')
- print('Введите свой ник:')
- io.read(7)
- MMenu()
- elseif lvl < MestoO1 then
- print('Поздравляю вы заняли 2ое место!')
- print('Введите свой ник:')
- io.read(7)
- MMenu()
- else
- print('Поздравляю вы заняли 1ое место!')
- print('Введите свой ник:')
- io.read(7)
- MMenu()
- end
- end
- function MMenu()
- term.clear()
- print (' <Главное меню>\n [1] Новая игра\n [2] Таблица рекордов\n [3] Описание\n [4] Выход\n\n')
- a = io.read()
- if a == "1" then
- print('Start Game!')
- lvl =0
- Game()
- elseif a == "2" then
- TRecord()
- elseif a == "3" then
- term.clear()
- print(' <Описание>\nЗа отведенное время надо\nуспеть ввести нужный\nнабор символом, при успехе,\nвы перейдете на следующий\nуровень.')
- io.read()
- MMenu()
- elseif a == "4" then
- term.clear()
- print("Спасибо за игру")
- os.sleep(1)
- term.clear()
- os.exit()
- else
- term.clear()
- print('Выберите один из пунктов (ввод цифры):')
- MMenu()
- end
- end
- MMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement