Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Автор: qwertyMAN
- -- Версия: 0.9 бета
- local term = require("term")
- local event = require("event")
- local component = require("component")
- local gpu = component.gpu
- -- устанавливаем переменные
- local games = {}
- local Active_Line = 1
- event.shouldInterrupt = function() return false end -- чтобы Alt + Ctrl + C не работал
- -- настройки
- local border = {1,1} -- отступы от экрана
- local draw_versions = false
- local colors = {
- Background = 0x000000,
- Foreground = 0xffffff,
- Active_Background = 0x000000,
- Active_Foreground = 0x0000ff,
- red = 0xff0000,
- green = 0x00ff00,
- blue = 0x0000ff,
- yellow = 0xffff00
- }
- local White_List = {"QwertyMAN","electronic_steve"} -- выдаём права администраторов
- local Black_List = {"LeshaInc","Fingercomp"} -- не разрешаем игрокам пользоваться компом
- -- функция загрузки
- local function add_game(gm)
- games[#games+1] = require(gm)
- end
- -- функции управления
- local command = {}
- command[28] = function()
- if games[Active_Line].func then
- local tb = games[Active_Line]
- tb.Black_List = Black_List
- tb.White_List = White_List
- tb.colors = colors
- tb.border = border
- games[Active_Line].func(tb)
- else
- term.clear()
- gpu.setForeground(colors.red)
- print("game not found")
- gpu.setForeground(colors.Foreground)
- os.sleep(2)
- end
- end
- command[23] = function()
- term.clear()
- if games[Active_Line].info then
- gpu.setForeground(colors.green)
- print(games[Active_Line].info)
- else
- gpu.setForeground(colors.red)
- print("info if a game not found")
- end
- os.sleep(2)
- gpu.setForeground(colors.Foreground)
- end
- command[200] = function()
- Active_Line=math.max(1,Active_Line-1)
- end
- command[208] = function()
- Active_Line=math.min(#games,Active_Line+1)
- end
- command[47] = function()
- if draw_versions then
- draw_versions = false
- else
- draw_versions = true
- end
- end
- -- загружаем игры
- add_game("Cube")
- add_game("snake")
- add_game("saper")
- -- устанавливаем цвет текста и фона по умолчанию
- gpu.setBackground(colors.Background)
- gpu.setForeground(colors.Foreground)
- -- отображаем список игр
- while true do
- term.clear()
- gpu.set(1+border[1], 1+border[2], "Games:")
- for i=1,#games do
- if not games[i].func then
- gpu.setForeground(colors.red)
- elseif tonumber(games[i].version) < 1 then
- gpu.setForeground(colors.yellow)
- else
- gpu.setForeground(colors.green)
- end
- if draw_versions then
- gpu.set(1+border[1], i+2+border[2], games[i].name.." v"..games[i].version)
- else
- gpu.set(1+border[1], i+2+border[2], games[i].name)
- end
- end
- gpu.setBackground(colors.Active_Background)
- gpu.setForeground(colors.Active_Foreground)
- if draw_versions then
- gpu.set(1+border[1], Active_Line+2+border[2], games[Active_Line].name.." v"..games[Active_Line].version)
- else
- gpu.set(1+border[1], Active_Line+2+border[2], games[Active_Line].name)
- end
- gpu.setBackground(colors.Background)
- gpu.setForeground(colors.Foreground)
- _,_,_, key, nick = event.pull("key_down")
- local swich = true
- for i=1, #Black_List do
- if nick == Black_List[i] then
- swich = false
- end
- end
- if swich then
- if key == 16 then -- позволяет выйти из программы всем кто в белом списке
- for i=1, #White_List do
- if White_List[i]==nick then
- term.clear()
- print("Exit")
- os.sleep(2)
- term.clear()
- return
- end
- end
- elseif command[key] then
- command[key]()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement