function stop() term.setTextColor(colors.white) term.clear() term.setCursorPos(1, 1) break end while true do print("Exiting program in 2 seconds") sleep(2) stop() endBecause, from the scope of the function, there is no loop to break, unless it is defined inside of the loop, as such:
while true do local function stop() term.setTextColor(colors.white) term.clear() term.setCursorPos(1, 1) break end print("Exiting program in 2 seconds") sleep(2) stop() end
Unfortunately, this function can only be used inside of the loop it is defined within, and loops nested inside that use the function will end the loop the function is defined in.
I would like to be provided with a function that can be defined once and end all loops, to ultimately stop the program, but while clearing the screen and stopping all loops.