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

Is there a way to edit the way a computer shuts down?

Started by claw106, 09 March 2014 - 05:36 AM
claw106 #1
Posted 09 March 2014 - 06:36 AM
When you go like reboot or shutdown. It just says goodbye. I want to be able to change that. Like you can with startup.
(e.g print("Welcome to your Computer")
but instead for shutdown it would be print("Shutting down") or something like that. Thanks!
Also is there a way to change its ID?
twormtwo #2
Posted 09 March 2014 - 07:25 AM
To make a custom shutdown/reboot program
Go on the computer, and edit a new file called shutdown (or reboot for the reboot program)

The computer uses the os.shutdown() and os.reboot() functions to shutdown/reboot the computer

The code that the computer runs when you normally type shutdown is as follows:

if term.isColour() then
term.setTextColour( colours.yellow )
end
print( "Goodbye" )
term.setTextColour( colours.white )
sleep( 1 )
os.shutdown()
It sets the text colour to yellow and prints goodbye, waits one second, then shuts the computer down. You can change any of this, or completely rewrite this for your custom shutdown.
Here is a simple example:

print("Shutting down!")
sleep(1)
os.shutdown()
It prints "Shutting down!", waits one second, and the shuts the computer off.
You can then do the same for the reboot, but change "os.shutdown()" with "os.reboot()".

And for changing computer ID's, it may be possible, but since I haven't personally had a need to, I haven't looked too deeply into if it is possible or not.

Hope I've helped :)/>
CometWolf #3
Posted 09 March 2014 - 10:16 AM
Why do you need to change the ID?