|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IPeripheral
The interface that defines a peripheral. This should be implemented by the TileEntity of any block that you wish to be interacted with by computer or turtle.
Method Summary | |
---|---|
void |
attach(IComputerAccess computer)
Is called when canAttachToSide has returned true, and a computer is attaching to the peripheral. |
java.lang.Object[] |
callMethod(IComputerAccess computer,
int method,
java.lang.Object[] arguments)
This is called when a lua program on an attached computer calls peripheral.call() with one of the methods exposed by getMethodNames(). Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe when interacting with minecraft objects. |
boolean |
canAttachToSide(int side)
Is called before the computer attempts to attach to the peripheral, and should return whether to allow the attachment. |
void |
detach(IComputerAccess computer)
Is called when a computer is detaching from the peripheral. |
java.lang.String[] |
getMethodNames()
Should return an array of strings that identify the methods that this peripheral exposes to Lua. |
java.lang.String |
getType()
Should return a string that uniquely identifies this type of peripheral. |
Method Detail |
---|
java.lang.String getType()
java.lang.String[] getMethodNames()
callMethod(dan200.computer.api.IComputerAccess, int, java.lang.Object[])
java.lang.Object[] callMethod(IComputerAccess computer, int method, java.lang.Object[] arguments) throws java.lang.Exception
computer
- The interface to the computer that is making the call. Remember that multiple
computers can be attached to a peripheral at once.method
- An integer identifying which of the methods from getMethodNames() the computer
wishes to call. The integer indicates the index into the getMethodNames() table
that corresponds to the string passed into peripheral.call()arguments
- An array of objects, representing the arguments passed into peripheral.call().java.lang.Exception
- If you throw any exception from this function, a lua error will be raised with the
same message as your exception. Use this to throw appropriate errors if the wrong
arguments are supplied to your method.getMethodNames()
boolean canAttachToSide(int side)
side
- The world direction (0=bottom, 1=top, etc) that the computer lies relative to the peripheral.
attach(dan200.computer.api.IComputerAccess)
void attach(IComputerAccess computer)
computer
- The interface to the computer that is being attached. Remember that multiple
computers can be attached to a peripheral at once.canAttachToSide(int)
,
detach(dan200.computer.api.IComputerAccess)
void detach(IComputerAccess computer)
computer
- The interface to the computer that is being detached. Remember that multiple
computers can be attached to a peripheral at once.canAttachToSide(int)
,
detach(dan200.computer.api.IComputerAccess)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |