-
Notifications
You must be signed in to change notification settings - Fork 0
English
For Mod Version: 1.0.6 Translated by Deepseek. This document describes the Lua function interfaces provided by the following peripherals:
-
Integrated Pose Sensor (
integrated_pose_sensor) -
Hologram Projector (
hologram) -
Void Engine (
void_engine) -
Glass Screen (extends the CC monitor
monitor) -
Keyboard (
keyboard)
Peripheral type: integrated_pose_sensor
Function: Read physical states such as centre of mass, mass, velocity, rotation matrix, etc. of a structure. All read methods require the structure to be in a simulated state, otherwise a LuaException is thrown.
Feature: Automatically computes combined physical structures (e.g., bearings and connectors).
- Description: Checks whether the structure containing this sensor is under physical simulation.
-
Return:
trueif simulated,falseotherwise (other read methods will fail).
- Description: Gets the world coordinates of the structure's centre of mass.
-
Return: A table with keys
x,y,z, allnumber(double-precision floating point).
- Description: Gets the total mass of the structure.
-
Return: Mass value (
double).
- Description: Gets the position of the sensor block itself in world space.
-
Return: A table with keys
x,y,z.
- Description: Gets the linear velocity of the structure's centre of mass (world coordinate system).
-
Return: A table with keys
x,y,z.
- Description: Gets the angular velocity of the structure (world coordinate system, in radians/second).
-
Return: A table with keys
x,y,z.
- Description: Gets the 3×3 rotation matrix of the structure's current orientation (row-major order).
-
Return: A list of three sublists, each containing three
numbers, e.g.,{{m00, m01, m02}, {m10, m11, m12}, {m20, m21, m22}}.
- Description: Gets the direction vectors of each face of the sensor in world space.
-
Return: A table with keys for directions (e.g.,
"up","down","north", etc.), values are{x, y, z}vectors.
- Description: Gets the current Euler angles of the sensor (rotations about X, Y, Z axes, in radians).
-
Return: A table with keys
x,y,z.
- Description: Gets the inertia tensor matrix of the structure (3×3).
-
Return: A 3×3 list in the same format as
getStructureRotationMatrix.
-
Description: Enables physics update event pushing. Once enabled, the peripheral pushes the
phy_tickevent to the connected computer every physics tick. - Default: Disabled.
- Description: Disables physics update event pushing.
- Description: Adds a block ID to the whitelist for composite physical body connections (recommended for physical bearings).
- Return: Whether the addition succeeded.
- Description: Removes a block ID from the composite physical body connection whitelist.
- Description: Physics tick event, pushed every physics tick.
-
Parameter format:
event_name,physics_state_snapshot -
event_name: The event name, always"phy_tick"for this event. -
physics_state_snapshot: A snapshot of the physical state, detailed below.
Returned by the
phy_tickevent, caching the physical state (position, velocity, etc.) of the structure at a given physics tick.
- Description: Gets the world coordinates of the structure's centre of mass.
-
Return: A table with keys
x,y,z.
- Description: Gets the position of the sensor (or snapshot reference point) in world space.
-
Return: A table with keys
x,y,z.
- Description: Gets the linear velocity of the structure's centre of mass (world coordinate system).
-
Return: A table with keys
x,y,z.
- Description: Gets the angular velocity of the structure (world coordinate system, radians/second).
-
Return: A table with keys
x,y,z.
- Description: Gets the 3×3 rotation matrix of the structure's current orientation (row-major).
-
Return: A list of three sublists, each with three
numbers.
- Description: Gets the direction vectors of each face of the snapshot reference point (sensor) in world space.
-
Return: A table with keys
"right","up","front", each value being a{x, y, z}vector.
- Description: Gets the Euler angles of the sensor (rotations about X, Y, Z axes, in radians).
-
Return: A table with keys
"yaw","pitch","roll".
- Description: Multiplies the given angular velocity (or angular impulse) vector by the inertia tensor, obtaining the corresponding angular momentum (or torque effect under inertia).
-
Parameters:
x,y,z– input vector components. -
Return: A table with keys
x,y,z– the resulting vector (matrix multiplicationinput * inertia).
- Description: Gets the inertia tensor matrix of the structure (3×3).
-
Return: A 3×3 list in the same format as
getStructureRotationMatrix.
Note: All methods of this object are read‑only and do not throw
LuaException(except for parameter errors, but all methods take no arguments or only numbers). It is suitable for storing and passing a physical state at a given moment, avoiding concurrency issues.
Peripheral type: hologram
Function: Manages multiple framebuffers, drawing pixels, lines, text, and supports copying (blitting) between buffers. All drawing operations are performed on the currently active framebuffer.
Colour: Range 0–255 (8‑bit), channel order (binary) is RRGGBBAA, each channel ranges 0–3, mapped to [0, 120, 200, 255].
- Description: Immediately synchronises the display buffer; takes effect only once per tick.
- Description: Sets the offset of the projection (coordinate shift).
- Description: Sets the rotation angles of the projection (in degrees).
- Description: Sets the scaling factor of the projection.
- Description: Gets the maximum number of pixels allowed for a single framebuffer (width × height upper limit).
- Return: Maximum pixel count (integer).
- Description: Gets the list of IDs of all currently allocated framebuffers.
- Return: A list of integer IDs.
- Description: Checks whether the framebuffer with the given ID is allocated.
-
Parameters:
id– buffer ID. -
Return:
trueif allocated.
- Description: Allocates a new framebuffer and returns its ID.
-
Parameters:
width,height– positive integers. -
Exception: Throws
LuaExceptionif width/height are non‑positive or exceed the maximum size. - Return: The newly allocated buffer ID.
- Description: Releases the framebuffer with the given ID.
- Exception: Throws if the ID does not exist.
- Description: Releases all allocated framebuffers.
- Description: Activates the framebuffer with the given ID; subsequent drawing operations will affect this buffer.
- Exception: Throws if the ID does not exist.
- Description: Resizes the currently active framebuffer. If the resize succeeds and the current buffer is the display buffer, it is automatically synchronised.
-
Exception: Throws
LuaExceptionif width/height are non‑positive or exceed the maximum size.
- Description: Exports the pixel data of the currently active framebuffer.
-
Return: A table containing
w(width),h(height), andpixels(a 1‑D byte array, each element a colour value 0–255). Pixels are stored in row‑major order.
- Description: Fills a rectangular area with a specified colour.
-
Parameters (in order):
-
ax– starting X coordinate (integer) -
ay– starting Y coordinate (integer) -
w– rectangle width (integer) -
h– rectangle height (integer) -
color– colour value (0–255) -
mode– (optional) fill mode, currently only0(solid overwrite) or1(solid) are supported; default0. Other modes are not yet enabled.
-
- Note: Coordinates outside the canvas are automatically clipped.
- Description: Copies the content of another framebuffer into the currently active buffer.
-
Parameters (in order):
-
ax– target starting X -
ay– target starting Y -
bufferId– source buffer ID -
mode– (optional) copy mode:0full overwrite,1clipped (copy only non‑transparent pixels); default0.
-
-
Exception: Throws if
bufferIdis invalid.
- Description: Copies a rectangular area from another framebuffer into the currently active buffer.
-
Parameters (in order):
-
ax– target starting X -
ay– target starting Y -
bx– source crop starting X -
by– source crop starting Y -
bw– source crop width -
bh– source crop height -
bufferId– source buffer ID -
mode– (optional) copy mode:0full overwrite,1clipped (copy only non‑transparent pixels); default0.
-
-
Exception: Throws if
bufferIdis invalid.
- Description: Copies pixels from a Lua table (pixel map) into the current buffer.
-
Parameters (in order):
-
ax– target starting X -
ay– target starting Y -
w– source image width -
h– source image height -
src– a table where keys are pixel indices (linear index starting from 0, typenumber) and values are colour values (0–255). -
mode– (optional) mode, same asblitFrameBuffer.
-
- Note: Only pixels present in the table are copied; others remain unchanged.
- Description: Draws a line segment using Bresenham's algorithm.
-
Parameters (in order):
-
x0,y0– start coordinates -
x1,y1– end coordinates -
color– colour value -
mode– (optional) drawing mode, currently only0(overwrite) or1(overwrite) are supported; default0. Mode2is not yet enabled.
-
- Note: The line is clipped to the canvas boundaries.
- Description: Draws a single pixel.
-
Parameters (in order):
-
x,y– coordinates -
color– colour value -
mode– (optional) mode, default0.
-
- Description: Enables or disables Unicode character conversion when drawing text.
-
Parameters:
enable–trueto enable conversion,falseto disable.
- Description: Draws text (using built‑in or custom font).
-
Parameters (in order):
-
x,y– starting coordinates (top‑left corner) -
text– string to draw (supports newline\n) -
color– colour value -
mode– (optional) drawing mode,0or1(clip transparent pixels), default1. -
fontName– (optional) font name. If not provided, the built‑in font is used.
-
- Exception: Throws if the specified font does not exist.
- Description: Gets the colour value of the pixel at the given coordinates.
-
Parameters:
x,y. - Return: Colour value (0–255).
- Exception: Throws if coordinates are out of bounds.
- Description: Clears the current framebuffer.
-
Parameters: (optional)
color– fill colour; if omitted, uses 0 (transparent/black).
Peripheral type: void_engine
Function: Applies linear and angular impulses to a physical structure, and queries energy and fluid reserves. All impulse application methods require the engine's structure to be in a simulated state.
- Description: Checks whether the engine is in a simulated structure.
-
Return:
trueif simulated.
- Description: Gets the energy storage capacity (FE).
- Return: Integer.
- Description: Gets the current energy stored (FE).
- Return: Integer.
- Description: Gets the fluid storage capacity (mB).
- Return: Integer.
- Description: Gets the current fluid amount (mB).
- Return: Integer.
- Description: Gets the current energy consumption rate (FE/tick).
- Return: Floating point number.
- Description: Gets the current fluid consumption rate (mB/tick).
- Return: Floating point number.
- Description: Adds a block ID to the whitelist for composite physical body connections (recommended for physical bearings).
- Return: Whether the addition succeeded.
- Description: Removes a block ID from the composite physical body connection whitelist.
- Description: Applies a linear force for one physics tick (world coordinate system), acting at the centre of mass.
- Parameters: Force components in three directions (units defined by the physics engine).
- Exception: Throws if not simulated.
- Description: Applies a torque for one physics tick (about world coordinate axes).
- Parameters: Components for the three axes.
- Exception: Throws if not simulated.
Note: Impulses are queued and applied at the next physics tick, consuming corresponding energy and fluid resources.
Peripheral type: Inherits from CC's monitor; the type name remains monitor, but it provides the following two additional functions.
- Description: Enables or disables the screen's transparent background mode.
-
Parameters:
mode–truefor transparent,falsefor opaque.
-
Description: Sets the "transparent colour" mapping for the background in transparent mode. The actual colour is taken from the character at index
colorin the string"0123456789abcdef"(colorshould be 0–15). -
Parameters:
color– integer 0–15. -
Exception: Throws
LuaExceptionifcoloris outside 0–15 (internally checked viaparseColour).
This class also inherits all standard monitor drawing functions (e.g.,
write,setCursorPos,clear, etc. – please refer to the official CC:T documentation for details). They are not repeated here.
Peripheral type: keyboard.
-
Description: Returns the peripheral type identifier, fixed to
"keyboard".
Note: This class does not expose any other Lua functions. Its main function is event pushing (when keys are pressed, events are sent to the connected computer).
Event types include
key,key_up,paste,char, identical to the keyboard events of the CC:T terminal. Refer to the official documentation onEventsfor details.