To do this, you are going to need to use the parallel.api. However, you may not be ready for that technique. Your simplest way might be to have a lever. that, when on, will allow the while loop to go. When off, it stops the while loop. You can modify the while loop to be while redstone.testBundledInput(side, color) do where the color is the color of the rednet cable connected to the lever.
To do the key press thing, you will need to turn the while loop into a function and have a separate function wait for a key event. Here is your code, re-written (and cleaned up a bit, setting local variables and functions where appropriate) which accomplishes what you asked for:
local function makeThings()
while true do
redstone.setBundledOutput("top",1)
--print ("ON") -- test line
sleep(13)
redstone.setBundledOutput("top",0)
--print ("OFF") -- test line
sleep(1)
print("Item made")
end
end
local function waitForKey()
while ({os.pullEvent("key")})[2] ~= keys.q do
end
end
print("You sure you want to choose the output 'white'?")
print("yes/no")
print(" ")
local choose = read()
term.clear()
term.setCursorPos(1,1)
if choose == "yes" then
parallel.waitForAny(makeThings,waitForKey)
elseif choose == "no" then
print("exiting to signal decision menu....")
sleep(3.0)
print("Loading menu:")
print(".")
sleep(3.0)
term.clearLine(3)
term.setCursorPos(1,3)
print("..")
sleep(3.0)
term.clearLine(3)
term.setCursorPos(1,3)
print("...")
sleep(3.0)
print("Loading successful")
sleep(2.0)
end
That will work the way you described. To quit, press the "q" key.
Mind you, there are more efficient ways to go about what you want to do, but this will work the way you want. I commented out the test print lines.
If you want to wait for any key, change the function waitForKey to this:
local function waitForKey()
while true do
os.pullEvent("key")
end
end
Please make sure to up vote the responses to your question that helped you. Several people contributed to helping you on your project. They like the feedback :)/>