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

Get drive from startup file in disk

Started by HometownPotato, 25 April 2014 - 06:39 PM
HometownPotato #1
Posted 25 April 2014 - 08:39 PM
If I have a startup script in a floppy disk, is there a way I can get the disk it is in? Since doing "/disk" will get me the first connected disk, it might give me a different disk if I have more than 1 disk drive.

So if I have 2+ disk drivers connected to a computer most with disks, and I insert a disk with a startup file, is there a way to know for sure which drive it was inserted in?

Of course a worst-case scenario that all the disks of drives have a startup file, so I can't just loop to check whether it has a startup file or not.

Is there a way? Or should I say, is it automatic? If I were to do a script from a startup file, would the CD already be the drive or?
Lyqyd #2
Posted 25 April 2014 - 09:29 PM
You can use shell.getRunningProgram to get the absolute path of the currently running program. If that doesn't work for whatever reason, give the disk a unique label and iterate the attached disk drives looking for it with disk.getLabel(side). When the side is found, use disk.getMountPath(side) to determine which disk folder it is.
HometownPotato #3
Posted 25 April 2014 - 09:37 PM
Oh I didn't think of that, thank you.
That leads me to the question, if there are multiple startup files all in disks, are they run at the same time?
Lyqyd #4
Posted 26 April 2014 - 12:00 AM
Only the first one found is used. The top side has first priority. It uses the table returned by rs.getSides.