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

Is it possible to wright a program that shuts the computer down after words.

Started by robonickinden, 03 April 2013 - 05:02 AM
robonickinden #1
Posted 03 April 2013 - 07:02 AM
I have written a program for a keycard door but I have it running on the startup file so before you can use it you have to restart the computer so I want to make it so when the key card finishes the program it runs the shutdown command. how would I do this?
BigSHinyToys #2
Posted 03 April 2013 - 07:06 AM
os.shutdown()
lewisholcombe #3
Posted 03 April 2013 - 07:54 AM
To make it tell you its shutting down and give it a few seconds you can do this.

sleep(1)
textutils.slowPrint("Shutting down...")
sleep(1)
(IF YOUR USING A DISK DRIVE ADD THE FOLLOWING BEFORE os.shutdown()
disk.eject("SIDE OF DISK DRIVE")
Engineer #4
Posted 03 April 2013 - 10:43 AM
To make it tell you its shutting down and give it a few seconds you can do this.

sleep(1)
textutils.slowPrint("Shutting down...")
sleep(1)
(IF YOUR USING A DISK DRIVE ADD THE FOLLOWING BEFORE os.shutdown()
disk.eject("SIDE OF DISK DRIVE")

textutils.slowPrint() ………………..

I know you want the 'real-computer feeling', but those textutils.slowPrint() and fake loading thingies are just ridicilous. Not to blame you, everyone who is starting out with programming in CC does it, but if you want the real computer feeling, make sure you have something to load.

However if you want to show text, then a sleep is good in its place. But slowPrint, I would not recommend it.

This is not only towards you, just a general thought. And if you think about it, it makes your program slower, wich most people dont want. Right?

NOTE: Please dont take this personal, it happens to be your post as example, the disk.eject is a smart add-on
PixelToast #5
Posted 03 April 2013 - 04:31 PM
i agree, slowprint is bad
though its usefull if you want the terminal to feel more retro