.
This commit is contained in:
parent
3064e35192
commit
17f68aa860
121
main/startup.lua
121
main/startup.lua
@ -3,6 +3,8 @@ local termWidth, termHeight = term.getSize()
|
|||||||
local selectedItem = 1
|
local selectedItem = 1
|
||||||
local inMainMenu = true
|
local inMainMenu = true
|
||||||
local inLightsMenu = false
|
local inLightsMenu = false
|
||||||
|
local color = "off"
|
||||||
|
|
||||||
|
|
||||||
--[[Menu Methods]]--
|
--[[Menu Methods]]--
|
||||||
function Choice1()
|
function Choice1()
|
||||||
@ -24,53 +26,60 @@ function Choice2()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
function LightsOn()
|
function LightsOn()
|
||||||
redstone.setBundledOutput("top", colors.white)
|
lightSystem("on", "white")
|
||||||
inLightsMenu = false
|
|
||||||
selectedItem = 1
|
|
||||||
end
|
end
|
||||||
function AlarmOn()
|
function AlarmOn()
|
||||||
redstone.setBundledOutput("top", colors.orange)
|
lightSystem("on", "red")
|
||||||
inLightsMenu = false
|
|
||||||
selectedItem = 1
|
|
||||||
end
|
end
|
||||||
function Off()
|
function LOff()
|
||||||
redstone.setBundledOutput("top", 0)
|
lightSystem("off", "white")
|
||||||
inLightsMenu = false
|
|
||||||
selectedItem = 1
|
|
||||||
end
|
end
|
||||||
function Snake()
|
function AOff()
|
||||||
shell.run("worm")
|
lightSystem("off", "red")
|
||||||
end
|
end
|
||||||
function LightsBack()
|
function LightsBack()
|
||||||
inLightsMenu = false
|
inLightsMenu = false
|
||||||
selectedItem = 1
|
selectedItem = 1
|
||||||
end
|
end
|
||||||
|
function AllOff()
|
||||||
|
lightSystem("off", "white")
|
||||||
|
lightSystem("off", "red")
|
||||||
|
end
|
||||||
|
|
||||||
|
function Snake()
|
||||||
|
shell.run("worm")
|
||||||
|
end
|
||||||
|
|
||||||
|
function Edit()
|
||||||
|
inMainMenu = false
|
||||||
|
end
|
||||||
|
|
||||||
function Reboot()
|
function Reboot()
|
||||||
print("Rebooting...")
|
print("Rebooting...")
|
||||||
sleep(1)
|
sleep(1)
|
||||||
os.reboot()
|
os.reboot()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Exit()
|
function Exit()
|
||||||
os.shutdown()
|
os.shutdown()
|
||||||
end
|
end
|
||||||
function Edit()
|
|
||||||
inMainMenu = false
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[Menu Definitions]]--
|
--[[Menu Definitions]]--
|
||||||
mainMenu = {
|
mainMenu = {
|
||||||
[1] = { text = "Who amI?",handler=Choice1 },
|
[1] = { text = "Who amI?",handler=Choice1 },
|
||||||
[2] = { text = "Light Controls",handler=Choice2 },
|
[2] = { text = "Light Controls",handler=Choice2 },
|
||||||
[3] = { text = "Snake",handler=Snake },
|
[3] = { text = "Snake",handler=Snake },
|
||||||
[4] = { text = "Reboot",handler=Reboot },
|
[4] = { text = "Edit program",handler=Edit },
|
||||||
[5] = { text = "Exit",handler=Exit },
|
[5] = { text = "Reboot",handler=Reboot },
|
||||||
[6] = { text = "Edit mode",handler=Edit }
|
[6] = { text = "Exit",handler=Exit }
|
||||||
}
|
}
|
||||||
lightsMenu={
|
lightsMenu={
|
||||||
[1]= { text="Lights On", handler=LightsOn},
|
[1]= { text="Lights On", handler=LightsOn},
|
||||||
[2]= { text="Alarm On", handler=AlarmOn},
|
[2]= { text="Alarm On", handler=AlarmOn},
|
||||||
[3]= { text="All Off", handler=Off},
|
[3]= { text="Lights Off", handler=LOff},
|
||||||
[4]= { text="Back", handler=LightsBack}
|
[4]= { text="Alarm Off", handler=AOff},
|
||||||
|
[5]= { text="All Off", handler=AllOff},
|
||||||
|
[6]= { text="Back", handler=LightsBack}
|
||||||
}
|
}
|
||||||
|
|
||||||
--[[Printing Methods]]--
|
--[[Printing Methods]]--
|
||||||
@ -107,7 +116,41 @@ function onItemSelected( menu )
|
|||||||
menu[selectedItem].handler()
|
menu[selectedItem].handler()
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[Main Method]]--
|
--[[Light System]]--
|
||||||
|
function lightSystem( op, type )
|
||||||
|
--[[On functions]]--
|
||||||
|
if color == "off" and op == "on" and type == "white" then
|
||||||
|
redstone.setBundledOutput("top", colors.white)
|
||||||
|
color = "white"
|
||||||
|
elseif color == "off" and op == "on" and type == "red" then
|
||||||
|
redstone.setBundledOutput("top", colors.red)
|
||||||
|
color = "red"
|
||||||
|
elseif color == "white" and op == "on" and type == "red" then
|
||||||
|
redstone.setBundledOutput("top", colors.white + colors.red)
|
||||||
|
color = "both"
|
||||||
|
elseif color == "red" and op == "on" and type == "white" then
|
||||||
|
redstone.setBundledOutput("top", colors.white + colors.red)
|
||||||
|
color = "both"
|
||||||
|
--[[Off functions]]--
|
||||||
|
elseif color == "both" and op == "off" and type == "white" then
|
||||||
|
redstone.setBundledOutput("top", colors.red)
|
||||||
|
color = "red"
|
||||||
|
elseif color == "both" and op == "off" and type == "red" then
|
||||||
|
redstone.setBundledOutput("top", colors.white)
|
||||||
|
color = "white"
|
||||||
|
elseif color == "white" and op == "off" and type == "white" then
|
||||||
|
redstone.setBundledOutput("top", 0)
|
||||||
|
color = "off"
|
||||||
|
elseif color == "red" and op == "off" and type == "red" then
|
||||||
|
redstone.setBundledOutput("top", 0)
|
||||||
|
color = "off"
|
||||||
|
else error("Light system error " .. op .. " " .. type .. " " .. color)
|
||||||
|
end
|
||||||
|
inLightsMenu = false
|
||||||
|
selectedItem = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[Main function]]--
|
||||||
function main()
|
function main()
|
||||||
while inMainMenu do
|
while inMainMenu do
|
||||||
term.clear()
|
term.clear()
|
||||||
@ -118,31 +161,29 @@ function main()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[Login]]--
|
--[[Login system]]--
|
||||||
function login()
|
function login()
|
||||||
os.pullEvent = os.pullEventRaw
|
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
print("2137_OS_v1.4 Login Screen")
|
print("Login:")
|
||||||
write("Password: ")
|
local username = read()
|
||||||
function pass()
|
|
||||||
t = io.read()
|
|
||||||
if t == "nigga" then
|
|
||||||
print ("Access Granted.")
|
|
||||||
sleep(2)
|
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
|
print("Password:")
|
||||||
|
local password = read("*")
|
||||||
|
if username == "ZareMate" and password == "nigga" then
|
||||||
|
main()
|
||||||
|
elseif username == "zaremate" and password == "nigga" then
|
||||||
|
main()
|
||||||
|
elseif username == "Querdus" and password == "kebab" then
|
||||||
|
main()
|
||||||
|
elseif username == "querdus" and password == "kebab" then
|
||||||
|
main()
|
||||||
else
|
else
|
||||||
print ("Incorrect Login Details.")
|
print("Wrong Password!")
|
||||||
sleep(1)
|
sleep(3)
|
||||||
term.clear()
|
os.reboot()
|
||||||
term.setCursorPos(1,1)
|
|
||||||
print("2137_OS_v1.3 Login Screen")
|
|
||||||
write("Password: ")
|
|
||||||
pass()
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
pass()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
login()
|
login()
|
||||||
main()
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user