li.cil.oc.api.machine
public interface Machine extends ManagedEnvironment, Context
Machine.create(Owner, Class). It is primarily
intended to be used by custom Architecture
implementations.| Modifier and Type | Method and Description |
|---|---|
void |
addUser(java.lang.String name)
Add a player to the machine's list of users, by username.
|
Architecture |
architecture()
The underlying architecture of the machine.
|
int |
componentCount()
The number of connected components.
|
java.util.Map<java.lang.String,java.lang.String> |
components()
The list of components attached to this machine.
|
double |
cpuTime()
The time spent running the underlying architecture in execution threads,
i.e.
|
boolean |
crash(java.lang.String message)
Crashes the computer.
|
java.lang.String |
documentation(java.lang.String address,
java.lang.String method)
Retrieves the docstring for the specified method of the specified
component.
|
double |
getCostPerTick()
Gets the amount of energy this machine consumes per tick when it is
running.
|
java.lang.Object[] |
invoke(java.lang.String address,
java.lang.String method,
java.lang.Object[] args)
Makes the machine call a component callback.
|
java.lang.String |
lastError()
A string with the last error message.
|
Owner |
owner()
The owner of the machine, usually a tile entity hosting the machine.
|
Signal |
popSignal()
Tries to pop a signal from the queue and returns it.
|
boolean |
removeUser(java.lang.String name)
Removes a player as a user from this machine, by username.
|
java.lang.String |
romAddress()
The address of the file system that holds the machine's read only data
(rom).
|
void |
setCostPerTick(double value)
Sets the amount of energy this machine consumes per tick when it is
running.
|
java.lang.String |
tmpAddress()
The address of the file system that holds the machine's temporary files
(tmpfs).
|
double |
upTime()
The time that has passed since the machine was started, in seconds.
|
java.lang.String[] |
users()
The list of users registered on this machine.
|
long |
worldTime()
The current world time.
|
canUpdate, updatenode, onConnect, onDisconnect, onMessageload, saveOwner owner()
Architecture architecture()
java.util.Map<java.lang.String,java.lang.String> components()
int componentCount()
components()).double getCostPerTick()
void setCostPerTick(double value)
value - the energy consumed per tick by the machine.java.lang.String romAddress()
Machine.addRomResource(Class, java.util.concurrent.Callable, String).
This may return null if the creation of the file system
failed.
Use this in a custom architecture to allow code do differentiate the
tmpfs from other file systems, for example.java.lang.String tmpAddress()
java.lang.String lastError()
crash(String) method), or when it fails to start (which,
technically, is also a crash).
When the machine started, this is reset to null.long worldTime()
double upTime()
double cpuTime()
Architecture.runThreaded(boolean) since
the machine was last started, in seconds.boolean crash(java.lang.String message)
Context.stop(), except that it also
sets the error message in the machine. This message can be seen when the
Analyzer is used on computer cases, for example.message - the message to set.Signal popSignal()
java.lang.Object[] invoke(java.lang.String address,
java.lang.String method,
java.lang.Object[] args)
throws java.lang.Exception
address - the address of the component to call the method on.method - the name of the method to call.args - the list of arguments to pass to the callback.LimitReachedException - when the called method supports direct
calling, but the number of calls in this
tick has exceeded the allowed limit.java.lang.IllegalArgumentException - if there is no such component.java.lang.Exception - if the callback throws an exception.java.lang.String documentation(java.lang.String address,
java.lang.String method)
Callback
annotation.address - the address of the component.method - the name of the method.java.lang.String[] users()
Context.canInteract(String). Exposed for
informative purposes only, for example to expose it to user code. Note
that the returned array is a copy of the internal representation of the
user list. Changing it has no influence on the actual list.void addUser(java.lang.String name)
throws java.lang.Exception
name - the name of the player to add as a user.java.lang.Exception - if
boolean removeUser(java.lang.String name)
name - the name of the player to remove.