basicly when u open the pc it asks you if you want to start and closes a iron door
then it starts asking questions and then u awnser them one by one
after u finished it opens a door for 5 seconds
then restarts
-- Question and Answer configuration --
local question1 = "What color hair do you have?" -- The first question that is asked.
local answer1 = "Black" -- Answer to question 1, and is case sensitive.
local question2 = "What color teeth do you have?" -- The second question that is asked.
local answer2 = "White" -- Answer to question 2, and is case sensitive.
local question3 = "What is your friend's name?" -- The third question that is asked.
local answer3 = "Bob" -- Answer to question 3, and is case sensitive.
local question4 = "What is your mother's name?" -- The fourth question that is asked.
local answer4 = "Rebecca" -- Answer to question 4, and is case sensitive
local question5 = "What is your dad's name?" -- The fifth and last question that is asked.
local answer5 = "Dave" -- Answer to question 5, and is case sensitive.
local doorside = "right" -- Change this to one of the following sides: right, left, top, bottom, back, or front. This side will open the iron doors.
-- A function (Don't mess with it!) --
function usedoor()
rs.setOutput(doorside, true)
print("Door Opened!")
os.sleep(1)
o, p = term.getCursorPos()
write("Remaining Time: 8")
term.setCursorPos(o, p)
os.sleep(1)
write("Remaining Time: 7")
term.setCursorPos(o, p)
os.sleep(1)
write("Remaining Time: 6")
term.setCursorPos(o, p)
os.sleep(1)
write("Remaining Time: 5")
term.setCursorPos(o, p)
os.sleep(1)
write("Remaining Time: 4")
term.setCursorPos(o, p)
os.sleep(1)
write("Remaining Time: 3")
term.setCursorPos(o, p)
os.sleep(1)
write("Remaining Time: 2")
term.setCursorPos(o, p)
os.sleep(1)
write("Remaining Time: 1")
term.setCursorPos(o, p)
os.sleep(1)
write("Remaining Time: 0")
os.sleep(.5)
print("nDoor Closed!")
rs.setOutput(doorside, false)
os.sleep(1)
os.shutdown()
end
-- The code --
term.clear()
term.setCursorPos(1,1)
print("Would you like to start?")
write("n> ")
local input = read()
if input == "Yes" or input == "yes" then
print("nThen please answer the following questions.")
os.sleep(1.5)
print("nQuestion 1:")
os.sleep(1.5)
write(question1 .. ": ")
Answerone = read()
print("nQuestion 2:")
os.sleep(1,5)
write(question2 .. ": ")
Answertwo = read()
print("nQuestion 3:")
os.sleep(1.5)
write(question3 .. ": ")
Answerthree = read()
print("nQuestion 4:")
os.sleep(1.5)
write(question4 .. ": ")
Answerfour = read()
print("nQuestion 5:")
os.sleep(1.5)
write(question5 .. ": ")
Answerfive = read()
if Answerone == answer1 and Answertwo == answer2 and Answerthree == answer3 and Answerfour == answer4 and Answerfive == answer5 then
print("nAll questions answered were correct! Congradulations!")
os.sleep(1.5)
usedoor()
else
print("nYou missed the answer to a question! Not opening the door!")
os.sleep(3)
os.shutdown()
end
elseif input == "No" or input == "no" then
print("nOk!")
os.sleep(1.5)
os.shutdown()
end
Since I am bored I think I could write some code for you on what I think you want… But you will have to edit the code to your specifications beyond that. Also, there is a max/min of 5 questions… Meaning that you can't change that number unless you know how to. :D/>/> By the way, the answers to the questions are not related to me in any way… So don't get your hopes up. ;)/>/>
You may change the questions and the answers! Just make sure that question1 goes with answer1, ect. Then make sure to put the answer or question in quotes, if it isn't…
Save this file as "startup" on the computer you want to use this for.-- Question and Answer configuration -- local question1 = "What color hair do you have?" -- The first question that is asked. local answer1 = "Black" -- Answer to question 1, and is case sensitive. local question2 = "What color teeth do you have?" -- The second question that is asked. local answer2 = "White" -- Answer to question 2, and is case sensitive. local question3 = "What is your friend's name?" -- The third question that is asked. local answer3 = "Bob" -- Answer to question 3, and is case sensitive. local question4 = "What is your mother's name?" -- The fourth question that is asked. local answer4 = "Rebecca" -- Answer to question 4, and is case sensitive local question5 = "What is your dad's name?" -- The fifth and last question that is asked. local answer5 = "Dave" -- Answer to question 5, and is case sensitive. local doorside = "right" -- Change this to one of the following sides: right, left, top, bottom, back, or front. This side will open the iron doors. -- A function (Don't mess with it!) -- function usedoor() rs.setOutput(doorside, true) print("Door Opened!") os.sleep(1) o, p = term.getCursorPos() write("Remaining Time: 8") term.setCursorPos(o, p) os.sleep(1) write("Remaining Time: 7") term.setCursorPos(o, p) os.sleep(1) write("Remaining Time: 6") term.setCursorPos(o, p) os.sleep(1) write("Remaining Time: 5") term.setCursorPos(o, p) os.sleep(1) write("Remaining Time: 4") term.setCursorPos(o, p) os.sleep(1) write("Remaining Time: 3") term.setCursorPos(o, p) os.sleep(1) write("Remaining Time: 2") term.setCursorPos(o, p) os.sleep(1) write("Remaining Time: 1") term.setCursorPos(o, p) os.sleep(1) write("Remaining Time: 0") os.sleep(.5) print("nDoor Closed!") rs.setOutput(doorside, false) os.sleep(1) os.shutdown() end -- The code -- term.clear() term.setCursorPos(1,1) print("Would you like to start?") write("n> ") local input = read() if input == "Yes" or input == "yes" then print("nThen please answer the following questions.") os.sleep(1.5) print("nQuestion 1:") os.sleep(1.5) write(question1 .. ": ") Answerone = read() print("nQuestion 2:") os.sleep(1,5) write(question2 .. ": ") Answertwo = read() print("nQuestion 3:") os.sleep(1.5) write(question3 .. ": ") Answerthree = read() print("nQuestion 4:") os.sleep(1.5) write(question4 .. ": ") Answerfour = read() print("nQuestion 5:") os.sleep(1.5) write(question5 .. ": ") Answerfive = read() if Answerone == answer1 and Answertwo == answer2 and Answerthree == answer3 and Answerfour == answer4 and Answerfive == answer5 then print("nAll questions answered were correct! Congradulations!") os.sleep(1.5) usedoor() else print("nYou missed the answer to a question! Not opening the door!") os.sleep(3) os.shutdown() end elseif input == "No" or input == "no" then print("nOk!") os.sleep(1.5) os.shutdown() end
-- your questions
local questions = {
"What color hair do you have?",
"What color teeth do you have?",
"What is your friend's name?",
"What is your mother's name?",
"What is your dad's name?"
}
-- your corresponding answers
-- the first question will have the first answer.
local answers = {
"Black",
"White",
"Bob",
"Rebecca",
"Dave"
}
-- asks the user if they wanna start.
print 'Would you like to begin?'
-- this is the complicated part. read() returns whatever the user types.
-- it then makes all of the letters in the input lowercase, and checks for the first letter only.
-- it will continue if the user has input "YES", "yes", or "Yes please"
if read():lower():sub(1,1) == 'y' then
print 'Let us begin then.'
sleep(1)
else
print 'Alright, never mind.'
sleep(1)
os.reboot()
end
-- start the loop of questioning
local num = 1
local result = true
-- keep going over this loop while the question number is less than or equal to
-- the number of questions.
-- in this case, it stops going at 6.
while num <= #question do
-- clear the screen in preparation for the next question.
term.clear()
-- using the parallel API to count down and take user input at the same time.
parallel.waitForAny(
-- this targets the first line of the console, and prints the question and time there
function()
for time=8, 1, -1 do
term.setCursorPos(1,1)
print(questions[num]..' (Time: '..time..')')
sleep(1)
end
result = false
end
-- at the end of this counting cycle, it'll skip the user input
-- because of "wait for any"
,
-- this targets the second line, and takes user input there
-- so that it doesn't interfere with the first line.
function()
term.setCursorPos(1,2)
-- checking for case insensative answers
-- lowercasing both all of the answer and all of the input
local input = read():lower()
if input ~= answers[num]:lower() then
result = false
end
end
-- at the end of this, it skips the timer because of "wait for any"
)
-- our result variable is what tells us if the user has ran out of time,
-- or has answered incorrectly. if it is false, get us out of the loop and
-- don't ask any more questions.
if not result then break end
-- otherwise, keep doing to the next question.
num = num + 1
end
-- clear the screen again to print the result of the questioning
term.clear()
term.setCursorPos(1,1)
-- if nothing went wrong and the result variable was never set to false
-- open the door for us :D/>/>
if result then
print 'Good job.'
rs.setOutput('right', true) -- change this to the side your door is on, of course.
sleep(5)
rs.setOutput('right', false) -- same here
-- if the variable is false, just reboot the system.
else
print 'Wrong.'
sleep(1)
os.reboot()
end
I don't know who this was directed to, but I could use this quite a bit to learn about tables. Because I am pretty stupid when it comes to tables. :D/>/>-- your questions local questions = { "What color hair do you have?", "What color teeth do you have?", "What is your friend's name?", "What is your mother's name?", "What is your dad's name?" } -- your corresponding answers -- the first question will have the first answer. local answers = { "Black", "White", "Bob", "Rebecca", "Dave" } -- asks the user if they wanna start. print 'Would you like to begin?' -- this is the complicated part. read() returns whatever the user types. -- it then makes all of the letters in the input lowercase, and checks for the first letter only. -- it will continue if the user has input "YES", "yes", or "Yes please" if read():lower():sub(1,1) == 'y' then print 'Let us begin then.' sleep(1) else print 'Alright, never mind.' sleep(1) os.reboot() end -- start the loop of questioning local num = 1 local result = true -- keep going over this loop while the question number is less than or equal to -- the number of questions. -- in this case, it stops going at 6. while num <= #question do -- clear the screen in preparation for the next question. term.clear() -- using the parallel API to count down and take user input at the same time. parallel.waitForAny( -- this targets the first line of the console, and prints the question and time there function() for time=8, 1, -1 do term.setCursorPos(1,1) print(questions[num]..' (Time: '..time..')') sleep(1) end result = false end -- at the end of this counting cycle, it'll skip the user input -- because of "wait for any" , -- this targets the second line, and takes user input there -- so that it doesn't interfere with the first line. function() term.setCursorPos(1,2) -- checking for case insensative answers -- lowercasing both all of the answer and all of the input local input = read():lower() if input ~= answers[num]:lower() then result = false end end -- at the end of this, it skips the timer because of "wait for any" ) -- our result variable is what tells us if the user has ran out of time, -- or has answered incorrectly. if it is false, get us out of the loop and -- don't ask any more questions. if not result then break end -- otherwise, keep doing to the next question. num = num + 1 end -- clear the screen again to print the result of the questioning term.clear() term.setCursorPos(1,1) -- if nothing went wrong and the result variable was never set to false -- open the door for us ;)/>/> if result then print 'Good job.' rs.setOutput('right', true) -- change this to the side your door is on, of course. sleep(5) rs.setOutput('right', false) -- same here -- if the variable is false, just reboot the system. else print 'Wrong.' sleep(1) os.reboot() end
If someone brings up the point of how "newbies aren't looking for efficiency", we're writing the program for him anyway so it doesn't really matter.
EDIT: In retrospect, I didn't really shorten it that much :S