Miscellaneous Helpers

This page collects some small classes that are used at various points throughout the code.


The class VisibleBlock is a representation of a block, including its connections to other


VisibleBlock.new(BlockSpecification value)
VisibleBlock.new(BlockSpecification value, View view)
Constructs an instance whose specification is given by the given value and, optionally, with the given view. Other members may be modified after construction, if needed.


View view
The view of global coordinates from the block's perspective.
Movement firstMovement
The movement of the block in the first half of a step.
Movement secondMovement
The movement of the block in the second half of a step.
BoolDirectionMap connections
Which directions, in local coordinates, the block is connected to.
LongDirectionMap lateralStrengths
The amount of shearing forces that can be resisted along the connections in each direction.
LongDirectionMap tensileStrengths
The amount of tensile forces that can be resisted along the connections in each direction.
(unspecified) pointer
A unique value associated to each block.
BlockSpecification what
A detailed description of the block's properties.


The class ExtraBlockData is a member of all block types and is used to store data about painting and some optional extra data.


Orientation base_orientation
The orientation of the block's texture with respect to its physical position.
Int base_index
The index of the block's texture in the texture table. Must be between 0 and 255.
Int userdata
An extra slot for scripts to use as they wish. This is not used in the standard library. Must be between 0 and 2^32 - 1.


This class is used to track nodes in the electrical network.


ElectricNodeReference.new(Vector position, Int index)
Constructs a reference referring to a node on a block at the given position. The index argument is used to disambiguate between blocks with multiple nodes - this should be 0 for blocks with only one node. The positive pin of a sensor is index 0 and the inverted pin is index 1.


Vector where
The position of the block who owns this node.
Int index
The index of the node selected.


The class Message is a value that can be serialized and communicated between scripts running on different threads or between saves and loads. It is typically not used directly; function accepting an argument of this type also accept any argument that could instead be passed to the constructor.


Message.new(Value value)
Creates a message with the contents specified by value. This value must either be: nil; an instance of String, Number, Boolean, Direction, Movement, Orientation, View, Vector, CellFace, CellView, GraphicalEntity, VisibleBlock, or BlockSpecification; or a table whose keys are all numbers or strings and whose values satisfy these requirements.

Member Functions

Value read()
Reconstructs the contents of the message. Note that this creates an independent copy of the message; changes in the returned value do not affect the message object itself.


The class Blueprint represents a series of interactions around some center.


Blueprint.new(vector<Interaction> interactions, Vectord center)
Create a blueprint with the specified interactions and center.
Blueprint.welder(Int tensile_strength, Int lateral_strength)
Creates a blueprint for a welder with the specified parameters.


vector<Interaction> placements
The interactions composing this blueprint.
Vectord center
The center of the blueprint.


The class ElectricStatus represents the possible signals present in the electric network. It can take on the following values:

The STUCK signal occurs when the system fails to resolve a loop involving sensors looking through portals controlled by other sensors - where the loop involves at least one inverting signal and is not determined by outside forces. ## Alignment The class Alignment represents the options for aligning text or figures. It can take on the following values: The values specify whether a reference point should be interpreted as the lower coordinate, center coordinate, or upper coordinate of an object. # Helper Functions
Interaction transform_interaction(Interaction interaction, CoordinateTransform transform)
Applies the specified transform to the given interaction.