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

Help with running a program on restart!

Started by JustynCarter, 05 April 2014 - 02:48 AM
JustynCarter #1
Posted 05 April 2014 - 04:48 AM
Hi, I was wondering how I would start a computer on restart (Such as in single player) without having to manually having to restart the computer by accessing it. Thanks!
Bomb Bloke #2
Posted 05 April 2014 - 09:21 AM
A computer/turtle should automatically start when its chunk loads (so long as it was running when that chunk unloaded), though some older versions of ComputerCraft have been reported as a bit buggy in this regard.

When starting, they'll execute the script "startup" (assuming that exists on their drive).
RoD #3
Posted 05 April 2014 - 02:13 PM
now, if you want to do a specific script i would do something like:

function reboot(arg)
  rb = fs.open("startup", "w")
  rb.write(arg)
  rb.close()
  os.reboot()
end
reboot("shell.run('proj/game')")
This would save a file to the startup for what to do next after rebooting.
Edited on 05 April 2014 - 01:42 PM
theoriginalbit #4
Posted 05 April 2014 - 03:19 PM
now, if you want to do a specific script i would do something like:

function reboot(arg)
  rb = fs.open("startup", "w")
  rb.write(arg)
  rb.close()
  os.reboot()
end
reboot("shell.run(proj/game")
This would save a file to the startup for what to do next after rebooting.
that'd save a syntax error… the last line should read

reboot("shell.run('proj/game')")
RoD #5
Posted 05 April 2014 - 03:43 PM
yup, forgot the ' and the ) thnx :)/>