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

get label and/or id of disk

Started by GalacticCow, 29 May 2014 - 03:36 PM
GalacticCow #1
Posted 29 May 2014 - 05:36 PM
At this point, I am making a system which will allow one to retrieve a specific floppy disk from my storage system. So, for instance, if I wanted to grab my "defense_system_backup" floppy disk, I would type in "retrieve defense_system_backup" and the computer(s) would find the disk in my storage and spit it out at me. It's a solution for my growing library of program backups and useful recurring scripts I use, but more importantly just a cool thing to make.

I have a basic idea of how I would do this. In the simplest sense, I would go through my disks one by one until it finds the specific disk, and ejects it out of the disk drive. I could include some optimizations based on my sorting system (if I search for "Defense_system_backup" it only searches through my backups chest), but the most base-case system would be a one-by-one system of looking through disks.

I have a few ideas of how I would implement this. The basic idea would be to use buildcraft to siphon/pipe disks into the disk drive, analyze them, and then pull them out/bring them in using the wooden pipes. Of course, simple computercraft redstone outputs would make this a cinch. However, I've run into an issue.

I have no idea how to check if the disk is the right one.

Basically, is there a "disk.getLabel()" function? Or if not, is there a disk.getID() function I could use instead (deferring to a printed catalogue of IDs for reference)?

Another question, is there a way to check between the disks' colors (so I could color-code similar disks to help with sorting)?

Again, another question, would it be possible to do the same thing between computercraft print-outs, or vanilla minecraft written books (program manuals)?

And finally, is there some other easy way to do this that I'm totally not picking up on?

Thanks!
KingofGamesYami #2
Posted 29 May 2014 - 07:59 PM
Since I assume you are storing a file on your disks, you could use fs.exists( filepath ) to determine if the given file is on the disk. I'm not sure if the labels on disks serve any purpose whatsoever. I do know you cannot read a piece of paper, much less a book, without a custom peripheral.

Edit: apparently there is a command for this… disk.getLabel( side )
Edited on 29 May 2014 - 06:09 PM
CCJJSax #3
Posted 29 May 2014 - 08:07 PM
Yeah there is. use disk.getLabel(string side) also, this api wiki will help you I think
Bomb Bloke #4
Posted 30 May 2014 - 01:26 AM
Though I reckon the disk API will only help you if the disk is in a drive a computer has access to. Assuming the "storage system" doesn't consist of a ton of computers with disk drives next to them, you'd need to cycle disks in/out of a single disk drive in order to find the correct one were you to use it.

OpenPeripheral can give you more information about items in most storage blocks, but I don't believe it can distinguish one disk from another. Still, if your computer knew the identity of a disk when it went into storage, then OpenPeripheral could be used to put it into a specific inventory slot - knowing that, the computer would be able to pinpoint that slot later when handling a retrieval request, assuming a player doesn't come along and start moving things around…