Startup

From ComputerCraft Wiki
Jump to: navigation, search

Startup Scripts

If, upon booting, a computer terminal detects a script named "startup" in its root directory, this script will be run. Similarly, if a disk is present in an attached disk drive containing a script named "startup" that script will be run. Disk autorun scripts take precedence over root directory autorun. This means if both the root directory and the disk contain a file called "startup" the one on the disk will be executed.

Very simple auto-install script to set up a single-use terminal (e.g. password-protected door):

Disk contents:

/disk/startup (installer script)
/disk/startup.file (program to be installed on terminal)

The script could look like:

 fs.copy("disk/startup.file", "startup")
 shell.run("startup")

When the disk is placed into a drive attached to a terminal, and the terminal is rebooted - the startup file on the disk will run. This startup file serves only to copy the program you've named "startup.file" to the root directory of the terminal with the new name "startup" - this will then run each time the terminal is booted, eliminating the need for the disk drive.