Last active
July 22, 2022 22:00
-
-
Save TheBunnyMan123/e3d17fe6517301c95d25a3ae753fa4da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
term.setCursorPos(1,1) | |
local firmwareName = "BunnyOS" | |
local author = "TheKillerBunny" | |
local firmwareVersion = "0.1" | |
term.clear() | |
print("Welcome to "..firmwareName.." version "..firmwareVersion) | |
print("This firmware was made by "..author) | |
function password() | |
local passFile = fs.open("./user", "r") | |
local pass = passFile.readLine() | |
passFile.close() | |
print("What is your password? ") | |
if read("*") == pass then | |
return true; | |
else | |
password() | |
end | |
end | |
os.pullEvent = os.pullEventRaw | |
if fs.exists("./user") then | |
password() | |
else | |
local file = fs.open("./user", "w") | |
print("What would you like your password to be?") | |
file.writeLine(read()) | |
file.close() | |
password() | |
end | |
-- Menu | |
-- set width and height variables | |
local w,h = term.getSize() | |
local optionNum = 1 | |
function printCentered(y, str) | |
term.setCursorPos((w - string.len(str))/2, y) | |
term.clearLine() | |
term.write(str) | |
end | |
-- draw menu | |
function mainMenu() | |
term.clear() | |
term.setCursorPos(0,0) | |
printCentered(1,"BunnyOS version 1.0") | |
term.setCursorPos(1,1) | |
write("ID: "..os.computerID()) | |
printCentered(h-1,"Made by TheKillerBunny") | |
printCentered((h/2)-2,"Main Menu") | |
if optionNum == 1 then | |
printCentered(h/2,"[ Programs ]") | |
printCentered((h/2)+1,"Shutdown") | |
end | |
if optionNum == 2 then | |
printCentered(h/2,"Programs") | |
printCentered((h/2)+1,"[ Shutdown ]") | |
end | |
end | |
-- Display | |
mainMenu() | |
while true do | |
local event, key = os.pullEvent() | |
if event == "key" then | |
if keys.getName(key) == "w" or keys.getName(key) == "up" then | |
if optionNum == 1 then | |
optionNum = 2 | |
mainMenu() | |
elseif optionNum == 2 then | |
optionNum = 1 | |
mainMenu() | |
end | |
elseif keys.getName(key) == "s" or keys.getName(key) == "down" then | |
if optionNum == 1 then | |
optionNum = 2 | |
mainMenu() | |
elseif optionNum == 2 then | |
optionNum = 1 | |
mainMenu() | |
end | |
elseif keys.getName(key) == "enter" then | |
break | |
end | |
end | |
end | |
-- Conditions | |
if optionNum == 1 then | |
function programs() | |
term.clear() | |
term.setCursorPos(0,0) | |
printCentered(1,"BunnyOS version 1.0") | |
printCentered(h-1,"Made by TheKillerBunny") | |
printCentered((h/2)-2,"Programs") | |
if optionNum == 1 then | |
printCentered(h/2,"[ Restart ]") | |
printCentered((h/2)+1,"Command Line") | |
printCentered((h/2)+2,"Edit File") | |
end | |
if optionNum == 2 then | |
printCentered(h/2,"Restart") | |
printCentered((h/2)+1,"[ Command Line ]") | |
printCentered((h/2)+2,"Edit File") | |
end | |
if optionNum == 3 then | |
printCentered(h/2,"Restart") | |
printCentered((h/2)+1,"Command Line") | |
printCentered((h/2)+2,"[ Edit File ]") | |
end | |
if optionNum == 4 then | |
printCentered(h/2,"Restart") | |
printCentered((h/2)+1,"Command Line") | |
printCentered((h/2)+2,"Edit File") | |
end | |
end | |
programs() | |
while true do | |
local event, key = os.pullEvent() | |
if event == "key" then | |
if keys.getName(key) == "s" or keys.getName(key) == "down" then | |
if optionNum < 3 then | |
optionNum = optionNum + 1 | |
programs() | |
elseif optionNum == 3 then | |
optionNum = 1 | |
programs() | |
end | |
elseif keys.getName(key) == "w" or keys.getName(key) == "up" then | |
if optionNum > 1 then | |
optionNum = optionNum - 1 | |
programs() | |
elseif optionNum == 1 then | |
optionNum = 3 | |
programs() | |
end | |
elseif keys.getName(key) == "enter" then | |
break | |
elseif keys.getName(key) == "backspace" then | |
term.clear() | |
term.setCursorPos(h/2,(w/2)-4) | |
shell.run("shutdown") | |
end | |
end | |
end | |
--conditions | |
if optionNum == 1 then | |
term.clear() | |
term.setCursorPos(h/2,(w/2)-4) | |
shell.run("reboot") | |
elseif optionNum == 2 then | |
term.clear() | |
term.setCursorPos(1,1) | |
print("Welcome to the terminal. To get back to the GUI type in `reboot`") | |
print("---------------------------------------------------") | |
shell.run("shell") | |
elseif optionNum == 3 then | |
term.clear() | |
term.setCursorPos(1,1) | |
print("What file would you like to edit? (if file does not exist a new one will be created)") | |
shell.run("edit "..read()) | |
end | |
elseif optionNum == 2 then | |
term.clear() | |
term.setCursorPos(h/2,(w/2)-4) | |
shell.run("shutdown") | |
end | |
term.setCursorPos(0,0) | |
shell.run("shutdown") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment