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

Questions about making peripherals

Started by Konlab, 28 September 2015 - 04:58 PM
Konlab #1
Posted 28 September 2015 - 06:58 PM
1. I put CC in the libs folder and CodeChickenCore in eclipse/mods folder and not sure if my installation is done, bevause I heard that you need to put the cc api somewhere but i cant find where i heard that. Its working, CC is there (maybe thats the source of my peripheral dont working)
2. What has to implement IPeripheral: the block or the TileEntity attached to the block? I tried the TE but not sure.
3. How can I return a lua table containing lua functions doing java-side things? Do I have to make a special class?
4. How peripherals can make their own folders in computers attached to them? (E.g. moar peripherals adds a moarp folder in computers)
SquidDev #2
Posted 28 September 2015 - 08:40 PM
1. I put CC in the libs folder and CodeChickenCore in eclipse/mods folder and not sure if my installation is done, bevause I heard that you need to put the cc api somewhere but i cant find where i heard that. Its working, CC is there (maybe thats the source of my peripheral dont working)

You don't need to include the CC API as it is packaged with the CC jar. I personally don't include it as then you don't have version incompatibility issues.

2. What has to implement IPeripheral: the block or the TileEntity attached to the block? I tried the TE but not sure.
The Javadoc is slightly misleading on this one. It doesn't matter where IPeripheral is implemented (I prefer a separate class for clarity). However you'll need to implement an instance of IPeripheralProvider and return the IPeripheral for your TE from it.

3. How can I return a lua table containing lua functions doing java-side things? Do I have to make a special class
You're probably looking for ILuaObject, it is implemented similarly to IPeripheral.

4. How peripherals can make their own folders in computers attached to them? (E.g. moar peripherals adds a moarp folder in computers)
Have a look at the mount and createResourceMount methods - they should allow you to do what you need. Be aware of the fact that attaching two of your peripherals, and then detaching the original will also unmount your mod's drive.
Konlab #3
Posted 29 September 2015 - 02:49 PM
1. I put CC in the libs folder and CodeChickenCore in eclipse/mods folder and not sure if my installation is done, bevause I heard that you need to put the cc api somewhere but i cant find where i heard that. Its working, CC is there (maybe thats the source of my peripheral dont working)

You don't need to include the CC API as it is packaged with the CC jar. I personally don't include it as then you don't have version incompatibility issues.

2. What has to implement IPeripheral: the block or the TileEntity attached to the block? I tried the TE but not sure.
The Javadoc is slightly misleading on this one. It doesn't matter where IPeripheral is implemented (I prefer a separate class for clarity). However you'll need to implement an instance of IPeripheralProvider and return the IPeripheral for your TE from it.

3. How can I return a lua table containing lua functions doing java-side things? Do I have to make a special class
You're probably looking for ILuaObject, it is implemented similarly to IPeripheral.

4. How peripherals can make their own folders in computers attached to them? (E.g. moar peripherals adds a moarp folder in computers)
Have a look at the mount and createResourceMount methods - they should allow you to do what you need. Be aware of the fact that attaching two of your peripherals, and then detaching the original will also unmount your mod's drive.
Thanks for your very detailed answer!
Konlab #4
Posted 29 September 2015 - 06:12 PM
I got my peripheral working!
Thank you very much!
http://imgur.com/um22qsS