public interface IPeripheral
Modifier and Type | Method and Description |
---|---|
void |
attach(IComputerAccess computer)
Is called when canAttachToSide has returned true, and a computercraft is attaching to the peripheral.
|
java.lang.Object[] |
callMethod(IComputerAccess computer,
ILuaContext context,
int method,
java.lang.Object[] arguments)
This is called when a lua program on an attached computercraft 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. |
void |
detach(IComputerAccess computer)
Is called when a computercraft is detaching from the peripheral.
|
boolean |
equals(IPeripheral other)
TODO: Document me
|
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.
|
java.lang.String getType()
java.lang.String[] getMethodNames()
callMethod(dan200.computercraft.api.peripheral.IComputerAccess, dan200.computercraft.api.lua.ILuaContext, int, java.lang.Object[])
java.lang.Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, java.lang.Object[] arguments) throws LuaException, java.lang.InterruptedException
computer
- The interface to the computercraft that is making the call. Remember that multiple
computers can be attached to a peripheral at once.context
- The context of the currently running lua thread. This can be used to wait for events
or otherwise yield.method
- An integer identifying which of the methods from getMethodNames() the computercraft
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.LuaException
java.lang.InterruptedException
getMethodNames()
void attach(IComputerAccess computer)
computer
- The interface to the computercraft that is being attached. Remember that multiple
computers can be attached to a peripheral at once.detach(dan200.computercraft.api.peripheral.IComputerAccess)
void detach(IComputerAccess computer)
computer
- The interface to the computercraft that is being detached. Remember that multiple
computers can be attached to a peripheral at once.detach(dan200.computercraft.api.peripheral.IComputerAccess)
boolean equals(IPeripheral other)