This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Snow van Night's profile picture

exit a program and wait for a new comand

Started by Snow van Night, 20 January 2015 - 06:06 PM
Snow van Night #1
Posted 20 January 2015 - 07:06 PM
Hey guys,
I try to close a program but when i use term.clear() and shell.exit() the terminal went to the last used Background color and i can´t enter a new command.
I try os.reboot but it is not what i want.

So, how can i close the program, set the terminal back to black and let it wait in the first line for a comand.
Edited on 20 January 2015 - 06:07 PM
KingofGamesYami #2
Posted 20 January 2015 - 07:32 PM
term.setBackgroundColor( colors.black )
term.setCursorPos( 1, 1 )
Snow van Night #3
Posted 20 January 2015 - 08:16 PM
I already tried to use:

term.setBackgroundColor(32768)
term.setCursorPos(1,1)
term.clear()
shell.exit()

but then it is not possible to use commands and the ">" symbol isn't present.
InDieTasten #4
Posted 20 January 2015 - 08:18 PM
but then it is not possible to use commands and the ">" symbol isn't present.
Thats rather odd I must say. Are you sure it exits the shell and continues to the shell?
Snow van Night #5
Posted 20 January 2015 - 08:25 PM
the monitor is cleared and black
no ">"

the program i write draw pixels over the complete monitor.
And when i use strg + t it says Goodbye and shut down, so yes: the program is closed!
Edited on 20 January 2015 - 07:32 PM
InDieTasten #6
Posted 20 January 2015 - 08:33 PM
You may be crashing the computer in a way that it performs a panic shutdown. how does the texture look like, when you escape from the terminal gui?
Snow van Night #7
Posted 20 January 2015 - 08:35 PM
computerFrontOnAdvanced.png

(working texture)
InDieTasten #8
Posted 20 January 2015 - 08:55 PM
And are you able to Ctrl-T (terminate) layers of applications underlying your program?
Snow van Night #9
Posted 20 January 2015 - 09:01 PM
seems that i found the reason: sell.exit doesn't close the infinite loop.
i replace the

term.setBackgroundColor(32768)
term.setCursorPos(1,1)
term.clear()
shell.exit()
with

break
and write

term.setBackgroundColor(32768)
term.setCursorPos(1,1)
term.clear()
at the end of the code.
Now it works.


Anyone know why shell.exit() don't close this?
Edited on 20 January 2015 - 08:02 PM
SquidDev #10
Posted 20 January 2015 - 10:04 PM
I don't think Shell.exit doesn't exit your program, it exits the current shell. So when you exit your program, you've already quit the shell, so the computer shuts down.
Bomb Bloke #11
Posted 21 January 2015 - 01:24 AM
That's always been my understanding. Odd that the wiki reckons it should only terminate the shell if the shell is the only thing running - how, in that instance, would you get the shell to perform that call?

I think someone confused it with the exit() function available to the Lua command prompt. Hmm, does that one work within other scripts? I can't remember if I'd tested it… Surely I would've done. Only way I've found to make a script end at a specific point is to call error().

I'll play around with it a bit later.

Edit: Yeah the wiki was just plain wrong. Fixed now.

And exit() is indeed only available to the Lua prompt. So the only way I'm aware of to terminate a script at a specific line remains as being to call error() (which, so long as you don't pass it any parameters, won't actually generate an on-screen error message - it'll just kill your script).
Edited on 22 January 2015 - 01:00 AM