What I'd like it to do is to first ask for a password. If you get it right, it activates the redstone beneath it which triggers the nuke, and then starts a countdown on screen from 20 to 0, and then reset back to the startup.
What it is doing right now, is when the password is correct, it activates the redstone and gives me my confirmation message, but then instead of a countdown starting it loops back to the password screen. I could have sworn I ended the loop but as I said I'm still new so I'm sure I made a mistake somewhere.
Also if anyone has any tips for helping me "clean up" my code work a little I'd love the feedback :)/>
Here's the code:
--[[
MAKE A DETONATE SEQUENCE THAT ACTIVATES THE NUKE AND STARTS A COUNTDOWN FROM 20 TO 0, THEN RESETS.
]]
s = 20 -- Variable for later in the countdown section
while true do
term.clear()
term.setCursorPos(1,1)
write ("Enter the password to start the detonation sequence: ")
local input = read()
if input == "Nuketown" then
term.clear()
term.setCursorPos(1,1)
write ("Correct. Starting detonation sequence.")
sleep (2)
rs.setOutput ("bottom", true)
sleep (1)
rs.setOutput ("bottom", false)
else
term.clear()
term.setCursorPos(1,1)
write ("Incorrect")
sleep (2)
end
end -- This is where it loops back to the first "while true do" function. So after correctly inputting the password and everything activating, it goes back through the loop.
while true do -- I want it to start here when the previous "end" is done, instead of loop back to the first "while true do" function
term.clear()
term.setCursorPos(1,1)
write ("Detonation in: "..s)
s = s-1
if s == 0 then
term.clear()
term.setCursorPos(1,1)
error()
end
end