dan200.computer.api
Interface IComputerAccess


public interface IComputerAccess

The interface passed to peripherals by computers or turtles, providing methods that they can call. This should not be implemented by your classes. Do not interact with computers except via this interface.


Method Summary
 java.lang.String getAttachmentName()
          Get a string, unique to the computer, by which the computer refers to this peripheral.
 int getID()
          Returns the numerical ID of this computer.
This is the same number obtained by calling os.getComputerID() or running the "id" program from lua, and is guarunteed unique.
 java.lang.String mount(java.lang.String desiredLocation, IMount mount)
          Mount a mount onto the computers' file system in a read only mode.
 java.lang.String mountWritable(java.lang.String desiredLocation, IWritableMount mount)
          Mount a mount onto the computers' file system in a writable mode.
 void queueEvent(java.lang.String event, java.lang.Object[] arguments)
          Causes an event to be raised on this computer, which the computer can respond to by calling os.pullEvent().
 void unmount(java.lang.String location)
          Unmounts a directory previously mounted onto the computers file system by mount() or mountWritable().
When a directory is unmounted, it will disappear from the computers file system, and the user will no longer be able to access it.
 

Method Detail

mount

java.lang.String mount(java.lang.String desiredLocation,
                       IMount mount)
Mount a mount onto the computers' file system in a read only mode.

Parameters:
desiredLoction - The location on the computer's file system where you would like the mount to be mounted.
mount - The mount object to mount on the computer. These can be obtained by calling ComputerCraftAPI.createSaveDirMount(), ComputerCraftAPI.createResourceMount() or by creating your own objects that implement the IMount interface.
Returns:
The location on the computer's file system where you the mount was actually mounted, this may be different from desiredLocation if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
See Also:
ComputerCraftAPI#createSaveDirMount(World, String), ComputerCraftAPI.createResourceMount(Class, String, String), mountWritable(String, IWritableMount), unmount(String), IMount

mountWritable

java.lang.String mountWritable(java.lang.String desiredLocation,
                               IWritableMount mount)
Mount a mount onto the computers' file system in a writable mode.

Parameters:
desiredLoction - The location on the computer's file system where you would like the mount to be mounted.
mount - The mount object to mount on the computer. These can be obtained by calling ComputerCraftAPI.createSaveDirMount() or by creating your own objects that implement the IWritableMount interface.
Returns:
The location on the computer's file system where you the mount was actually mounted, this may be different from desiredLocation if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
See Also:
ComputerCraftAPI#createSaveDirMount(World, String), ComputerCraftAPI.createResourceMount(Class, String, String), mount(String, IMount), unmount(String), IMount

unmount

void unmount(java.lang.String location)
Unmounts a directory previously mounted onto the computers file system by mount() or mountWritable().
When a directory is unmounted, it will disappear from the computers file system, and the user will no longer be able to access it. All directories mounted by a mount or mountWritable are automatically unmounted when the peripheral is attached if they have not been explicitly unmounted.

Parameters:
location - The desired location in the computers file system of the directory to unmount. This must be the location of a directory previously mounted by mount() or mountWritable(), as indicated by their return value.
See Also:
mount(String, IMount), mountWritable(String, IWritableMount)

getID

int getID()
Returns the numerical ID of this computer.
This is the same number obtained by calling os.getComputerID() or running the "id" program from lua, and is guarunteed unique. This number will be positive.

Returns:
The identifier.

queueEvent

void queueEvent(java.lang.String event,
                java.lang.Object[] arguments)
Causes an event to be raised on this computer, which the computer can respond to by calling os.pullEvent(). This can be used to notify the computer when things happen in the world or to this peripheral.

Parameters:
event - A string identifying the type of event that has occurred, this will be returned as the first value from os.pullEvent(). It is recommended that you you choose a name that is unique, and recognisable as originating from your peripheral. eg: If your peripheral type is "button", a suitable event would be "button_pressed".
arguments - In addition to a name, you may pass an array of extra arguments to the event, that will be supplied as extra return values to os.pullEvent(). Objects in the array will be converted to lua data types in the same fashion as the return values of IPeripheral.callMethod().
You may supply null to indicate that no arguments are to be supplied.
See Also:
IPeripheral.callMethod(dan200.computer.api.IComputerAccess, dan200.computer.api.ILuaContext, int, java.lang.Object[])

getAttachmentName

java.lang.String getAttachmentName()
Get a string, unique to the computer, by which the computer refers to this peripheral. For directly attached peripherals this will be "left","right","front","back",etc, but for peripherals attached remotely it will be different. It is good practice to supply this string when raising events to the computer, so that the computer knows from which peripheral the event came.

Returns:
A string unique to the computer, but not globally.