Components and signals
wackasm-opencomputers has a struct for every OpenComputers component type
(53 of them, 402 methods), generated from OpenComputers: Modernized’s own callbacks. Each
method keeps OpenComputers’ documentation, its Lua signature, and whether it
is a direct call.
With the crate’s async feature, every method also has an _async twin
(gpu.set_async(...)) that doesn’t block; see
Async programs.
Every method, with OpenComputers’ documentation for it, is in the API reference.
Finding components
Section titled “Finding components”Gpu::first(): the first one, by address;Gpu::all(): every one;Gpu::at(address): a specific one.
For a component the wrappers don’t know (another mod’s), use
component::Proxy or component::invoke(address, method, args), and
component::list(filter) / component::methods(address) to explore.
| Lua | parameter | optional parameter | return |
|---|---|---|---|
number |
impl Into<Number> (ints, f64, Side, Color) |
Option<Number> |
Number |
string |
impl AsRef<[u8]> (&str, bytes, Address) |
Option<&str> |
OcString |
boolean |
bool |
Option<bool> |
bool |
userdata |
Handle |
Option<Handle> |
Handle |
table, unions |
impl Into<Value> |
Option<Value> |
Value |
data... |
&[Value] |
||
X or nil |
Option<X> |
||
a, b |
(A, B) |
Number is an integer or a float, as OpenComputers sent it, so integers stay
exact. A reply of nil, "reason" becomes Err(Error::Failed(reason)).
Signals
Section titled “Signals”signal::pull(timeout) returns the next signal, typed: KeyDown, KeyUp,
Clipboard, Touch, Drag, Drop, Scroll, Walk, ComponentAdded,
ComponentRemoved, ComponentAvailable, ComponentUnavailable,
RedstoneChanged, Motion, ModemMessage, InventoryChanged, and Other
for anything else. signal::push queues one.
This computer
Section titled “This computer”computer::address(), uptime(), memory_limit(), beep(),
shutdown(), reboot(), crash(), log() (written to a log file on the
server), and files_disk().
Calls cost what they cost in Lua: direct calls draw on the per-tick call budget, and other calls wait for the next server tick. See Hardware.