Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local oldpull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- local password = "zipy"
- local function c(col)
- if term.isColor() then
- term.setTextColor(col)
- end
- end
- term.clear()
- local l, h = term.getSize()
- local function pos(x, y)
- term.setCursorPos(x, y)
- end
- local function w(string)
- local x, y = term.getCursorPos()
- term.write(string)
- y = y + 1
- pos(x, y)
- end
- local function border(height)
- c(colors.lime)
- local l1 = "**"
- for i = 5, l do
- l1 = l1 .. "="
- end
- l1 = l1 .. "**"
- local l2 = "||"
- pos(1, 1)
- w(l1)
- for i = 2, height - 1 do
- pos(1, i)
- w(l2)
- pos(l - 1, i)
- w(l2)
- end
- pos(1, height)
- w(l1)
- c(colors.white)
- end
- local function bunney(x, y)
- x = x - 3
- pos(x, y)
- c(colors.orange)
- w("(\\_/)")
- w("(',')")
- w("(\\\")(\")")
- pos(x - 3, y + 4)
- w("Chubby Bunney")
- c(colors.white)
- end
- local function star(x, y)
- pos(x, y)
- c(colors.lightBlue)
- w(" /\\")
- w("< >")
- w(" \\/")
- c(colors.white)
- end
- local function pass(x, y)
- x = x - 4
- pos(x, y)
- c(colors.lightGray)
- w("Please type")
- w(" Password:")
- pos(x, y + 5)
- w("-----------")
- pos(x, y + 3)
- w("-----------")
- c(colors.white)
- term.setCursorBlink(true)
- end
- local function build()
- border(18)
- star(4, 3)
- star(l - 6, 3)
- star(4, h - 4)
- star(l - 6, h - 4)
- bunney(l / 2, 3)
- pass((l / 2) - 1, 9)
- end
- build()
- local t = true
- while t do
- input = read("*")
- if input == password then
- t = false
- term.setCursorBlink(false)
- os.pullEvent = oldpull
- else
- term.clear()
- pos(1, 1)
- build()
- end
- end
- term.clear()
- --shell.run("test")
- local function getProgramsInDirectory()
- local programs = {}
- local files = fs.list(shell.dir())
- local programName = shell.getRunningProgram()
- for _, file in ipairs(files) do
- if not fs.isDir(file) and file ~= programName then
- table.insert(programs, {
- name = file,
- func = function() shell.run(file) end
- })
- end
- end
- return programs
- end
- local function displayMenu(menuOptions, selectedOption)
- term.clear()
- Pos(1,1)
- c(colors.red)
- w("Logged In To " .. os.getComputerLabel())
- c(colors.green)
- w("Select a program to run:")
- for idx, option in ipairs(menuOptions) do
- if idx == selectedOption then
- w("-> " .. option.name)
- else
- w(" " .. option.name)
- end
- end
- end
- local function handleChoice(choice, menuOptions)
- local option = menuOptions[choice]
- option.func()
- end
- local function main()
- local menuOptions = getProgramsInDirectory()
- table.insert(menuOptions, { name = "Exit", func = function() return end }) -- Insert an "Exit" option
- local selectedOption = 1
- displayMenu(menuOptions, selectedOption)
- while true do
- local event, key = os.pullEvent("key")
- if key == keys.w and selectedOption > 1 then
- selectedOption = selectedOption - 1
- displayMenu(menuOptions, selectedOption)
- elseif key == keys.s and selectedOption < #menuOptions then
- selectedOption = selectedOption + 1
- displayMenu(menuOptions, selectedOption)
- elseif key == keys.enter then
- handleChoice(selectedOption, menuOptions)
- if selectedOption == #menuOptions then -- Check if "Exit" was selected
- return
- end
- break
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement