ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: thetrue_dv on Mar 07, 2021, 11:42 PM

Title: Moving to Directory on startup.
Post by: thetrue_dv on Mar 07, 2021, 11:42 PM
Hello!

I like to organise my scripts into folders, that's pretty common...

What I'd like to do is basically run
cd <foldername> upon startup, so I don't have to manually do it every time I break the turtle to move it. How do I go about doing that?
Title: Moving to Directory on startup.
Post by: Lupus590 on Mar 08, 2021, 04:01 AM
There is an API for changing the current directory of the shell, calling it with the right argument in a startup file will do what you want.
Title: Moving to Directory on startup.
Post by: thetrue_dv on Mar 08, 2021, 01:38 PM
Just to confirm:
"shell.setDir("/rom")"?

It works, but working doesn't always mean the best way
Title: Moving to Directory on startup.
Post by: Lupus590 on Mar 08, 2021, 02:17 PM
Yep. The other way would be to shell.run to the cd program but it's considered bad practice to use shell.run like that.
Title: Moving to Directory on startup.
Post by: thetrue_dv on Mar 09, 2021, 01:23 AM
Awesome, thanks!