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

CC Doesn't Detect Peripheral

Started by wjykk, 08 October 2012 - 03:22 AM
wjykk #1
Posted 08 October 2012 - 05:22 AM
Hi all,

I followed the instructions on how to make a peripheral and all, but every time I try to use it with a computer, it doesn't detect that as a peripheral. So, if I do peripheral.isPresent("side"), it returns false.

The code for the TileEntity (which implements IPeripheral) is here, with the entire project here. If anyone has the time to analyze what's wrong, please help me fix the problem.

Thanks.
Pharap #2
Posted 08 October 2012 - 10:51 AM
I'm not a Java programmer, but I'm guessing this might be your issue:


public void attach(IComputerAccess computer, String computerSide) {
this.comp = computer;
}
You aren't assigning the peripheral to a side, thus when the computer checks the side, it doesn't register there being a peripheral there.
Might be wrong, but when there's an argument that isn't being used, there tends to be something going wrong somewhere.
Xfel #3
Posted 08 October 2012 - 11:23 AM
No, the peripheral.isPresent method should recognize it if the tile entity implements IPeripheral. everything else doesn't matter.
Xfel #4
Posted 08 October 2012 - 11:26 AM
What could matter is the part:

@Override
public boolean canAttachToSide(int side) {
return (this.comp == null) ? true : false;
}
I guess you want it to connect to only one computer. Why? Try changing it to return true alway, and it will work.
wjykk #5
Posted 09 October 2012 - 01:15 AM
I guess you want it to connect to only one computer. Why? Try changing it to return true alway, and it will work.
Great, that fixed the problem! Thanks for the tip.