and i was going to incorporate it but can't quite grasp it i guess since im trying to make one key go to a shutdown function and another key go back
any help is welcomed….
--Countdown to open door
-- Variables
--Door Variables
--Username
Username = "Admin"
--Password
Password = "Password1"
--Countdown Variables
--Number Variables
number = {}
number[0] = colors.cyan + colors.magenta + colors.yellow + colors.red + colors.green + colors.blue
number[1] = colors.magenta + colors.blue
number[2] = colors.cyan + colors.magenta + colors.black + colors.red + colors.green
number[3] = colors.cyan + colors.magenta + colors.black + colors.blue + colors.green
number[4] = colors.magenta + colors.yellow + colors.black + colors. blue
number[5] = colors.cyan + colors.yellow + colors.black + colors.blue + colors.green
number[6] = colors.cyan + colors.yellow + colors.black + colors.red + colors.green + colors.blue
number[7] = colors.cyan + colors.magenta + colors.blue
number[8] = colors.cyan + colors.magenta + colors.yellow + colors.black + colors.red + colors.green + colors.blue
number[9] = colors.cyan + colors.magenta + colors.yellow + colors.black + colors.green + colors.blue
--Functions
--clear all function
function clearall()
term.clear()
term.setCursorPos(1,1)
end
--Loadbar function
--(Thanks to xgaarocha)
--Link: http://www.computercraft.info/forums2/index.php?/topic/180-gaas-useful-functions/page__hl__loading__fromsearch__1
function loadbar(s, char, size)
-- Define parameters
s = s or 10
size = size or 20
char = char or "%"
local xpos,ypos = term.getCursorPos()
local delay = s/size
local start = 1
while start < size do
term.setCursorPos(start, ypos)
print (char)
sleep(delay)
start = start + 1
end
end
--countdown function
function countdown()
for x = 5,0 do
redstone.setBundledOutput("back", number[x])
sleep(2)
end
end
--Login screen making function
function Loginscreen()
term.setCursorPos(1,1)
print (" (@|")
term.setCursorPos(1,2)
print (" ,, ,)|_________________________________")
term.setCursorPos(1,3)
print ("//\\8@8@8@8 / _ B L A D E D E M O N 7 0 _ \ ")
term.setCursorPos(1,4)
print ("\\//8@8@8@8 \_________________________________/ ")
term.setCursorPos(1,5)
print (" `` `)|")
term.setCursorPos(1,6)
print (" (@|")
term.setCursorPos(12,7)
print ("+----------------------------+")
term.setCursorPos(12,8)
print ("|-----------Login:-----------|")
term.setCursorPos(12,9)
print ("+----------------------------+")
term.setCursorPos(12,10)
print ("| Username: |")
term.setCursorPos(12,11)
print ("+----------------------------+")
term.setCursorPos(12,12)
print ("| Password: |")
term.setCursorPos(12,13)
print ("+----------------------------+")
end
--Shutdown function
function Shutdown()
sleep(.5)
clearall()
print ("Shutting down...")
sleep(.5)
print ("Goodbye.")
sleep(.5)
os.shutdown()
end
--goto_mainmenu function
function goto_mainmenu()
sleep(.5)
mainmenu()
end
--Activate_Count function
function Activate_Count()
print ("Please direct your eyes to the Countdown display.")
print ("When the countdown hits 0, the door will open and you may proceed.")
print ("Starting now...")
countdown()
sleep(.5)
term.setBundledOutput("right", true)
sleep(5)
print ("Goodbye")
term.setBundledOutput("right", false)
sleep(.5)
os.reboot()
end
-- Quit_back function
function Quit_back()
sleep(.5)
clearall()
setCursorPos(1,11)
print ("Would you like to quit?")
print ("Press 'Q' to quit or 'B' to go back.")
event, param1, param2 = os.pullEvent()
if event == "key" and param1 == 113 then Shutdown() end
if event == "key" and param2 == 98 then goto_mainmenu() end
end
--Mainmenu function
function mainmenu()
clearall()
term.setCursorPos(12,1)
print ("+----------------------------+")
term.setCursorPos(12,2)
print ("|----------Blade.Os----------|")
term.setCursorPos(12,3)
print ("+----------------------------+")
term.setCursorPos(12,6)
print ("Welcome to the Terminal Control Panel.")
term.setCursorPos(1,8)
print ("Would you like to open the door?")
print ("Press 'Y' for Yes and 'N' for No...")
event, param1, param2 = os.pullEvent()
if event == "key" and param1 == 121 then Activate_Count() end --Y for yes 121 = y
if event == "key" and param2 == 110 then Quit_back() end --N for no 110 = n
end
--Main Program
clearall()
loadbar(s, char, size)
clearall()
sleep(.5)
Loginscreen()
term.setCursorPos(23,10)
local input = read()
if input == Username then
term.setCursorPos(23,12)
local input = read()
if input == Password then
sleep(.5)
mainmenu()
else -- incorrect password
sleep(.5)
clearall()
term.setCursorPos(1,1)
print ("Incorrect Password.")
sleep(.5)
print ("Shutting down....")
sleep(1)
os.shutdown()
end
else
sleep(.5)
clearall()
term.setCursorPos(1,1)
print ("System Crash...")
sleep(.5)
print ("Rebooting...")
sleep(1)
os.reboot()
end
--Countdown to open door
-- Variables
--Door Variables
--Username
Username = "Admin"
--Password
Password = "Password1"
--Countdown Variables
--Number Variables
number = {}
number[0] = colors.cyan + colors.magenta + colors.yellow + colors.red + colors.green + colors.blue
number[1] = colors.magenta + colors.blue
number[2] = colors.cyan + colors.magenta + colors.black + colors.red + colors.green
number[3] = colors.cyan + colors.magenta + colors.black + colors.blue + colors.green
number[4] = colors.magenta + colors.yellow + colors.black + colors. blue
number[5] = colors.cyan + colors.yellow + colors.black + colors.blue + colors.green
number[6] = colors.cyan + colors.yellow + colors.black + colors.red + colors.green + colors.blue
number[7] = colors.cyan + colors.magenta + colors.blue
number[8] = colors.cyan + colors.magenta + colors.yellow + colors.black + colors.red + colors.green + colors.blue
number[9] = colors.cyan + colors.magenta + colors.yellow + colors.black + colors.green + colors.blue
--Functions
--clear all function
function clearall()
term.clear()
term.setCursorPos(1,1)
end
--Loadbar function
--(Thanks to xgaarocha)
--Link: http://www.computercraft.info/forums2/index.php?/topic/180-gaas-useful-functions/page__hl__loading__fromsearch__1
function loadbar(s, char, size)
-- Define parameters
s = s or 10
size = size or 20
char = char or "%"
local xpos,ypos = term.getCursorPos()
local delay = s/size
local start = 1
while start < size do
term.setCursorPos(start, ypos)
print (char)
sleep(delay)
start = start + 1
end
end
--countdown function
function countdown()
for x = 5,0 do
redstone.setBundledOutput("back", number[x])
sleep(2)
end
end
--Login screen making function
function Loginscreen()
term.setCursorPos(1,1)
print (" (@|")
term.setCursorPos(1,2)
print (" ,, ,)|_________________________________")
term.setCursorPos(1,3)
print ("//\\8@8@8@8 / _ B L A D E D E M O N 7 0 _ \ ")
term.setCursorPos(1,4)
print ("\\//8@8@8@8 \_________________________________/ ")
term.setCursorPos(1,5)
print (" `` `)|")
term.setCursorPos(1,6)
print (" (@|")
term.setCursorPos(12,7)
print ("+----------------------------+")
term.setCursorPos(12,8)
print ("|-----------Login:-----------|")
term.setCursorPos(12,9)
print ("+----------------------------+")
term.setCursorPos(12,10)
print ("| Username: |")
term.setCursorPos(12,11)
print ("+----------------------------+")
term.setCursorPos(12,12)
print ("| Password: |")
term.setCursorPos(12,13)
print ("+----------------------------+")
end
--Shutdown function
function Shutdown()
sleep(.5)
clearall()
print ("Shutting down...")
sleep(.5)
print ("Goodbye.")
sleep(.5)
os.shutdown()
end
--goto_mainmenu function
function goto_mainmenu()
sleep(.5)
mainmenu()
end
--Activate_Count function
function Activate_Count()
print ("Please direct your eyes to the Countdown display.")
print ("When the countdown hits 0, the door will open and you may proceed.")
print ("Starting now...")
countdown()
sleep(.5)
term.setBundledOutput("right", true)
sleep(5)
print ("Goodbye")
term.setBundledOutput("right", false)
sleep(.5)
os.reboot()
end
-- Quit_back function
function Quit_back()
sleep(.5)
clearall()
setCursorPos(1,11)
print ("Would you like to quit?")
print ("Press 'Q' to quit or 'B' to go back.")
event, param1 = os.pullEvent()
if event == "char" and string.lower(param1) == "q" then Shutdown() end
if event == "char" and string.lower(param1) == "b" then goto_mainmenu() end
end
--Mainmenu function
function mainmenu()
clearall()
term.setCursorPos(12,1)
print ("+----------------------------+")
term.setCursorPos(12,2)
print ("|----------Blade.Os----------|")
term.setCursorPos(12,3)
print ("+----------------------------+")
term.setCursorPos(1,6)
print ("Welcome to the Terminal Control Panel.")
term.setCursorPos(1,8)
print ("Would you like to open the door?")
print ("Press 'Y' for Yes and 'N' for No...")
event, param1 = os.pullEvent()
if event == "char" and string.lower(param1) == "y" then Activate_Count() end --Y for yes 121 = y
if event == "char" and string.lower(param1) == "n" then Quit_back() end --N for no 110 = n
end
--Main Program
clearall()
loadbar(s, char, size)
clearall()
sleep(.5)
Loginscreen()
term.setCursorPos(23,10)
local input = read()
if input == Username then
term.setCursorPos(23,12)
local input = read()
if input == Password then
sleep(.5)
mainmenu()
else -- incorrect password
sleep(.5)
clearall()
term.setCursorPos(1,1)
print ("Incorrect Password.")
sleep(.5)
print ("Shutting down....")
sleep(1)
os.shutdown()
end
else
sleep(.5)
clearall()
term.setCursorPos(1,1)
print ("System Crash...")
sleep(.5)
print ("Rebooting...")
sleep(1)
os.reboot()
end
--Countdown to open door
-- Variables
--Door Variables
--Username
Username = "Admin"
--Password
Password = "Password1"
--Countdown Variables
--Number Variables
number = {}
number[0] = colors.cyan + colors.magenta + colors.yellow + colors.red + colors.green + colors.blue
number[1] = colors.magenta + colors.blue
number[2] = colors.cyan + colors.magenta + colors.black + colors.red + colors.green
number[3] = colors.cyan + colors.magenta + colors.black + colors.blue + colors.green
number[4] = colors.magenta + colors.yellow + colors.black + colors. blue
number[5] = colors.cyan + colors.yellow + colors.black + colors.blue + colors.green
number[6] = colors.cyan + colors.yellow + colors.black + colors.red + colors.green + colors.blue
number[7] = colors.cyan + colors.magenta + colors.blue
number[8] = colors.cyan + colors.magenta + colors.yellow + colors.black + colors.red + colors.green + colors.blue
number[9] = colors.cyan + colors.magenta + colors.yellow + colors.black + colors.green + colors.blue
--Functions
--clear all function
function clearall()
term.clear()
term.setCursorPos(1,1)
end
--Loadbar function
--(Thanks to xgaarocha)
--Link: http://www.computercraft.info/forums2/index.php?/topic/180-gaas-useful-functions/page__hl__loading__fromsearch__1
function loadbar(s, char, size)
-- Define parameters
s = s or 10
size = size or 20
char = char or "%"
local xpos,ypos = term.getCursorPos()
local delay = s/size
local start = 1
while start < size do
term.setCursorPos(start, ypos)
print (char)
sleep(delay)
start = start + 1
end
end
--countdown function
function countdown()
for x = 5,0 do
redstone.setBundledOutput("back", number[x])
sleep(2)
end
end
--Login screen making function
function Loginscreen()
term.setCursorPos(1,1)
print (" (@|")
term.setCursorPos(1,2)
print (" ,, ,)|_________________________________")
term.setCursorPos(1,3)
print ("//8@8@8@8 / _ B L A D E D E M O N 7 0 _ ")
term.setCursorPos(1,4)
print ("//8@8@8@8 _________________________________/ ")
term.setCursorPos(1,5)
print (" `` `)|")
term.setCursorPos(1,6)
print (" (@|")
term.setCursorPos(12,7)
print ("+----------------------------+")
term.setCursorPos(12,8)
print ("|-----------Login:-----------|")
term.setCursorPos(12,9)
print ("+----------------------------+")
term.setCursorPos(12,10)
print ("| Username: |")
term.setCursorPos(12,11)
print ("+----------------------------+")
term.setCursorPos(12,12)
print ("| Password: |")
term.setCursorPos(12,13)
print ("+----------------------------+")
end
--Shutdown function
function Shutdown()
sleep(.5)
clearall()
print ("Shutting down...")
sleep(.5)
print ("Goodbye.")
sleep(.5)
os.shutdown()
end
--goto_mainmenu function
function goto_mainmenu()
sleep(.5)
mainmenu()
end
--Activate_Count function
function Activate_Count()
print ("Please direct your eyes to the Countdown display.")
sleep(.5)
print ("When the countdown hits 0, the door will open and you may proceed.")
sleep(.5)
print ("Starting now...")
sleep(1)
countdown()
sleep(7)
print ("Opening...")
sleep(.5)
redstone.setBundledOutput("back", false)
redstone.setBundledOutput("right", true)
sleep(5)
print ("Goodbye")
redstone.setBundledOutput("right", false)
sleep(.5)
os.reboot()
end
-- Quit_back function
function Quit_back()
sleep(.5)
clearall()
setCursorPos(1,11)
print ("Would you like to quit?")
print ("Press 'Q' to quit or 'B' to go back.")
event, param1 = os.pullEvent("char")
if event == "char" and string.lower(param1) == "q" then Shutdown() end
if event == "char" and string.lower(param1) == "b" then goto_mainmenu() end
end
--Mainmenu function
function mainmenu()
clearall()
term.setCursorPos(12,1)
print ("+----------------------------+")
term.setCursorPos(12,2)
print ("|----------Blade.Os----------|")
term.setCursorPos(12,3)
print ("+----------------------------+")
term.setCursorPos(1,6)
print ("Welcome to the Terminal Control Panel.")
term.setCursorPos(1,8)
print ("Would you like to open the door?")
print ("Press 'Y' for Yes and 'N' for No...")
event, param1 = os.pullEvent("char")
if event == "char" and string.lower(param1) == "y" then Activate_Count() end --Y for yes 121 = y
if event == "char" and string.lower(param1) == "n" then Quit_back() end --N for no 110 = n
end
--Main Program
clearall()
loadbar(s, char, size)
clearall()
sleep(.5)
Loginscreen()
term.setCursorPos(23,10)
local input = read()
if input == Username then
term.setCursorPos(23,12)
local input = read()
if input == Password then
sleep(.5)
mainmenu()
else -- incorrect password
sleep(.5)
clearall()
term.setCursorPos(1,1)
print ("Incorrect Password.")
sleep(.5)
print ("Shutting down....")
sleep(1)
os.shutdown()
end
else
sleep(.5)
clearall()
term.setCursorPos(1,1)
print ("System Crash...")
sleep(.5)
print ("Rebooting...")
sleep(1)
os.reboot()
end
--Activate_Count function
function Activate_Count()
print ("Please direct your eyes to the Countdown display.")
sleep(.5)
print ("When the countdown hits 0, the door will open and you may proceed.")
sleep(.5)
print ("Starting now...")
sleep(1)
countdown()
sleep(7)
print ("Opening...")
sleep(.5)
redstone.setBundledOutput("back", false)
redstone.setBundledOutput("right", true)
sleep(5)
print ("Goodbye")
redstone.setBundledOutput("right", false)
sleep(.5)
os.reboot()
end
--Countdown Variables
--Number Variables
number = {}
number[0] = colors.cyan + colors.magenta + colors.yellow + colors.red + colors.green + colors.blue
number[1] = colors.magenta + colors.blue
number[2] = colors.cyan + colors.magenta + colors.black + colors.red + colors.green
number[3] = colors.cyan + colors.magenta + colors.black + colors.blue + colors.green
number[4] = colors.magenta + colors.yellow + colors.black + colors. blue
number[5] = colors.cyan + colors.yellow + colors.black + colors.blue + colors.green
number[6] = colors.cyan + colors.yellow + colors.black + colors.red + colors.green + colors.blue
number[7] = colors.cyan + colors.magenta + colors.blue
number[8] = colors.cyan + colors.magenta + colors.yellow + colors.black + colors.red + colors.green + colors.blue
number[9] = colors.cyan + colors.magenta + colors.yellow + colors.black + colors.green + colors.blue
--countdown function
function countdown()
for x = 5,0 do
redstone.setBundledOutput("back", number[x])
sleep(.5)
end
end
for x = 5, 0, -1 do