.
This commit is contained in:
parent
7fd0314ce8
commit
667003e51a
296
main/startup.lua
296
main/startup.lua
@ -1,148 +1,148 @@
|
|||||||
--[[Local Variables]]--
|
--[[Local Variables]]--
|
||||||
local termWidth, termHeight = term.getSize()
|
local termWidth, termHeight = term.getSize()
|
||||||
local selectedItem = 1
|
local selectedItem = 1
|
||||||
local inMainMenu = true
|
local inMainMenu = true
|
||||||
local inLightsMenu = false
|
local inLightsMenu = false
|
||||||
|
|
||||||
--[[Menu Methods]]--
|
--[[Menu Methods]]--
|
||||||
function Choice1()
|
function Choice1()
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
term.write("chuj")
|
term.write("chuj")
|
||||||
sleep(3)
|
sleep(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Choice2()
|
function Choice2()
|
||||||
selectedItem = 1
|
selectedItem = 1
|
||||||
inLightsMenu=true
|
inLightsMenu=true
|
||||||
while inLightsMenu do
|
while inLightsMenu do
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
printMenu(lightsMenu)
|
printMenu(lightsMenu)
|
||||||
event,key=os.pullEvent("key")
|
event,key=os.pullEvent("key")
|
||||||
onKeyPressed(key,lightsMenu)
|
onKeyPressed(key,lightsMenu)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function LightsOn()
|
function LightsOn()
|
||||||
redstone.setBundledOutput("top", colors.white)
|
redstone.setBundledOutput("top", colors.white)
|
||||||
inLightsMenu = false
|
inLightsMenu = false
|
||||||
selectedItem = 1
|
selectedItem = 1
|
||||||
end
|
end
|
||||||
function AlarmOn()
|
function AlarmOn()
|
||||||
redstone.setBundledOutput("top", colors.orange)
|
redstone.setBundledOutput("top", colors.orange)
|
||||||
inLightsMenu = false
|
inLightsMenu = false
|
||||||
selectedItem = 1
|
selectedItem = 1
|
||||||
end
|
end
|
||||||
function Off()
|
function Off()
|
||||||
redstone.setBundledOutput("top", 0)
|
redstone.setBundledOutput("top", 0)
|
||||||
inLightsMenu = false
|
inLightsMenu = false
|
||||||
selectedItem = 1
|
selectedItem = 1
|
||||||
end
|
end
|
||||||
function Snake()
|
function Snake()
|
||||||
shell.run("worm")
|
shell.run("worm")
|
||||||
end
|
end
|
||||||
function LightsBack()
|
function LightsBack()
|
||||||
inLightsMenu = false
|
inLightsMenu = false
|
||||||
selectedItem = 1
|
selectedItem = 1
|
||||||
end
|
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()
|
function Edit()
|
||||||
inMainMenu = false
|
inMainMenu = false
|
||||||
end
|
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 = "Reboot",handler=Reboot },
|
||||||
[5] = { text = "Exit",handler=Exit },
|
[5] = { text = "Exit",handler=Exit },
|
||||||
[6] = { text = "Edit mode",handler=Edit }
|
[6] = { text = "Edit mode",handler=Edit }
|
||||||
}
|
}
|
||||||
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="All Off", handler=Off},
|
||||||
[4]= { text="Back", handler=LightsBack}
|
[4]= { text="Back", handler=LightsBack}
|
||||||
}
|
}
|
||||||
|
|
||||||
--[[Printing Methods]]--
|
--[[Printing Methods]]--
|
||||||
function printMenu(menu)
|
function printMenu(menu)
|
||||||
for i=1,#menu do
|
for i=1,#menu do
|
||||||
if i== selectedItem then
|
if i== selectedItem then
|
||||||
print("[*]"..menu[i].text)
|
print("[*]"..menu[i].text)
|
||||||
else
|
else
|
||||||
print("[ ]"..menu[i].text)
|
print("[ ]"..menu[i].text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[Handler Method]]--
|
--[[Handler Method]]--
|
||||||
function onKeyPressed( key, menu )
|
function onKeyPressed( key, menu )
|
||||||
if key == keys.enter then
|
if key == keys.enter then
|
||||||
onItemSelected( menu )
|
onItemSelected( menu )
|
||||||
elseif key == keys.up then
|
elseif key == keys.up then
|
||||||
if selectedItem > 1 then
|
if selectedItem > 1 then
|
||||||
selectedItem = selectedItem - 1
|
selectedItem = selectedItem - 1
|
||||||
else
|
else
|
||||||
selectedItem = #menu
|
selectedItem = #menu
|
||||||
end
|
end
|
||||||
elseif key == keys.down then
|
elseif key == keys.down then
|
||||||
if selectedItem < #menu then
|
if selectedItem < #menu then
|
||||||
selectedItem = selectedItem + 1
|
selectedItem = selectedItem + 1
|
||||||
else
|
else
|
||||||
selectedItem = 1
|
selectedItem = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function onItemSelected( menu )
|
function onItemSelected( menu )
|
||||||
menu[selectedItem].handler()
|
menu[selectedItem].handler()
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[Main Method]]--
|
--[[Main Method]]--
|
||||||
function main()
|
function main()
|
||||||
while inMainMenu do
|
while inMainMenu do
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
printMenu(mainMenu)
|
printMenu(mainMenu)
|
||||||
event,key = os.pullEvent("key")
|
event,key = os.pullEvent("key")
|
||||||
onKeyPressed(key,mainMenu)
|
onKeyPressed(key,mainMenu)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[Login]]--
|
--[[Login]]--
|
||||||
function login()
|
function login()
|
||||||
os.pullEvent = os.pullEventRaw
|
os.pullEvent = os.pullEventRaw
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
print("2137_OS_v1.4 Login Screen")
|
print("2137_OS_v1.4 Login Screen")
|
||||||
write("Password: ")
|
write("Password: ")
|
||||||
function pass()
|
function pass()
|
||||||
t = io.read()
|
t = io.read()
|
||||||
if t == "nigga" then
|
if t == "nigga" then
|
||||||
print ("Access Granted.")
|
print ("Access Granted.")
|
||||||
sleep(2)
|
sleep(2)
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
else
|
else
|
||||||
print ("Incorrect Login Details.")
|
print ("Incorrect Login Details.")
|
||||||
sleep(1)
|
sleep(1)
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
print("2137_OS_v1.3 Login Screen")
|
print("2137_OS_v1.3 Login Screen")
|
||||||
write("Password: ")
|
write("Password: ")
|
||||||
pass()
|
pass()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
pass()
|
pass()
|
||||||
end
|
end
|
||||||
login()
|
login()
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user