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

[question] would a disk-like mod count as a peripheral?

Started by tesla1889, 12 November 2012 - 07:45 AM
tesla1889 #1
Posted 12 November 2012 - 08:45 AM
I want to make an item that has all the functionality of a disk in CC, but that has added functionality as well. Would this count as a peripheral, or what? And how would I do this?
Bubba #2
Posted 12 November 2012 - 08:49 AM
Anything that you can use peripheral.wrap() on would count as a peripheral. Look around the forums and see if you figure out how to make one - I'm still learning myself and it is somewhat of a proccess. I would suggest that you download a java decompiler such as JD GUI and decompiling some other people's peripherals to get a general idea of how it's done (do not copy/paste their code!).

To write peripherals you must use Minecraft Coder Pack to decompile Minecraft and then add the ComputerCraft peripheral apis located here to your project.
tesla1889 #3
Posted 12 November 2012 - 08:54 AM
That's all fine and dandy, but does anyone know how to add a disk to CC?
Espen #4
Posted 12 November 2012 - 12:33 PM
You could take a look at the disk class of ComputerCraft and use that as a guide for creating your own.
The problem is that you still need something to access your extended features, because the default disk drive won't be able to access them.
At most it can access only the parts of your disk that it has in common with the default disks.

So in addition to your disk you need to make your own disk-drive into which you can add the necessary code to access your features.
This drive will then be the peripheral that acts as an interface between your special disks and the computer.
Orwell #5
Posted 12 November 2012 - 12:43 PM
Maybe you could use the IMedia API that comes with CC 1.46? It doesn't really enable you to add extra functionality, it just lets you implement your own way to set and get labels, to get the title of a record and to mount data. If you do need extra functions, then Espen's way is how to do it. A custom disk drive.
tesla1889 #6
Posted 12 November 2012 - 02:17 PM
Maybe you could use the IMedia API that comes with CC 1.46? It doesn't really enable you to add extra functionality, it just lets you implement your own way to set and get labels, to get the title of a record and to mount data. If you do need extra functions, then Espen's way is how to do it. A custom disk drive.
Thank you Orwell, that sounds promising. Do you have a download link for that? The API I downloaded only has IComputerAccess and IPeripheral.
tesla1889 #7
Posted 12 November 2012 - 02:21 PM
You could take a look at the disk class of ComputerCraft and use that as a guide for creating your own.
The problem is that you still need something to access your extended features, because the default disk drive won't be able to access them.
At most it can access only the parts of your disk that it has in common with the default disks.

So in addition to your disk you need to make your own disk-drive into which you can add the necessary code to access your features.
This drive will then be the peripheral that acts as an interface between your special disks and the computer.
The only CC functionality exactly mimicks the CC disk. The rest of the mod is completely separate.
Orwell #8
Posted 12 November 2012 - 02:23 PM
Maybe you could use the IMedia API that comes with CC 1.46? It doesn't really enable you to add extra functionality, it just lets you implement your own way to set and get labels, to get the title of a record and to mount data. If you do need extra functions, then Espen's way is how to do it. A custom disk drive.
Thank you Orwell, that sounds promising. Do you have a download link for that? The API I downloaded only has IComputerAccess and IPeripheral.

Oh, well, it's definitely in the ComputerCraft mod itself: '/dan200/computer/api/IMedia.class'. You'll have to compile against it as a library to access it then. Or you could ask dan200 or Cloudy to publish the API, it's in the api folder anyway… :unsure:/>/>
Cloudy #9
Posted 13 November 2012 - 10:01 AM
The IMedia API isn't quite complete yet - hence why not released.