The printer3d component configures and starts OpenComputers 3D print jobs. It lets you build a print model out of cuboid shapes, define labels and tooltips, configure light and redstone behavior, choose collision rules, and commit the model for repeated printing.
- Repository:
opencomputers - Component name:
printer3d - Typical host: placed OpenComputers 3D printer
local component = require("component")
local printer = component.printer3d
if not printer then
error("printer3d component not installed")
end- A model is split into two shape sets:
stateOffstateOn
- At least one shape must exist in
stateOfffor the model to be printable. stateOnis optional and is used for active-state variants.- Each shape is one cuboid.
- Shape coordinates are clamped to the
0through16voxel range before being converted to normalized block coordinates.
- Maximum shapes per state are limited by
Settings.get.maxPrintComplexity. getMaxShapeCount()returns that configured value.- Labels are truncated to
24characters. - Tooltips are truncated to
128characters. - Light level is clamped to
0throughSettings.get.maxPrintLightLevel. - Redstone level is clamped to
0through15. commit(count)clampscountto0throughInteger.MAX_VALUE.
The 3D printer consumes:
- chamelium-derived print material
- printable ink
- energy from the OC network buffer
Model cost is based on:
- total shape volume for material
- total shape surface area for ink
- an extra material surcharge when custom redstone strength is used
- a noclip multiplier when either state is non-collidable
- Syntax:
printer.reset() - Returns: no meaningful value
- Purpose: Clears the current model configuration and cancels further queued printing.
Behavior:
- The current physical print already in progress is allowed to finish.
- The shape sets, label, tooltip, light, redstone, and collision settings are reset because a new empty
PrintDataobject is created.
- Syntax:
printer.setLabel(value) - Returns: no meaningful value
- Purpose: Sets the printed block label.
Parameters:
value:string: desired label, truncated to24characters.
Behavior:
- Empty strings become
nil.
- Syntax:
printer.getLabel() - Returns:
string|nil - Purpose: Returns the current pending print label.
- Syntax:
printer.setTooltip(value) - Returns: no meaningful value
- Purpose: Sets the printed block tooltip.
Parameters:
value:string: tooltip text, truncated to128characters.
Behavior:
- Empty strings become
nil.
- Syntax:
printer.getTooltip() - Returns:
string|nil - Purpose: Returns the current pending tooltip.
- Syntax:
printer.setLightLevel(value) - Returns: no meaningful value
- Purpose: Sets emitted light level for the printed block.
Parameters:
value:number: requested light level. The implementation clamps it to the configured maximum.
- Syntax:
printer.getLightLevel() - Returns:
number - Purpose: Returns the current configured light level.
- Syntax:
printer.setRedstoneEmitter(value) - Returns: no meaningful value
- Purpose: Configures active-state redstone output.
Parameters:
value:boolean|number:truesets redstone level to15falsesets redstone level to0- a number is clamped to
0through15
- Syntax:
printer.isRedstoneEmitter() - Returns:
boolean, number - Purpose: Returns whether the print emits redstone and which strength it uses.
- Syntax:
printer.setButtonMode(value) - Returns: no meaningful value
- Purpose: Sets whether the printed block should automatically return from the active state to the inactive state.
- Syntax:
printer.isButtonMode() - Returns:
boolean - Purpose: Returns the current button-mode flag.
- Syntax:
printer.setCollidable(collideOff, collideOn) - Returns: no meaningful value
- Purpose: Sets whether the printed block collides in the off and on states.
Parameters:
collideOff:booleancollideOn:boolean
Behavior:
- Internally this flips
noclipOffandnoclipOn.
- Syntax:
printer.isCollidable() - Returns:
boolean, boolean - Purpose: Returns the off-state and on-state collision flags.
- Syntax:
printer.addShape(minX, minY, minZ, maxX, maxY, maxZ, texture[, state=false][, tint]) - Returns:
- Success:
true - Failure:
nil, reason
- Success:
- Purpose: Adds one cuboid shape to the current model.
Parameters:
minX,minY,minZ:number: first corner in voxel coordinatesmaxX,maxY,maxZ:number: second corner in voxel coordinatestexture:string: texture name, truncated to64charactersstate:booleanoptional:falsefor the off-state shape set,truefor the on-state shape settint:numberoptional: tint value applied to the shape
Behavior:
- Coordinates are clamped to
0through16. minZandmaxZare flipped internally using16 - value.- If any dimension collapses to zero thickness, the callback throws
empty block. - If the shape count is already above the configured maximum, the callback returns
nil, "model too complex".
Example:
assert(printer.addShape(0, 0, 0, 16, 2, 16, "opencomputers:block/print"))- Syntax:
printer.getShapeCount() - Returns:
offCount, onCount - Purpose: Returns the number of shapes currently stored in the off and on states.
- Syntax:
printer.getMaxShapeCount() - Returns:
number - Purpose: Returns the configured maximum shape count per state.
- Syntax:
printer.commit([count]) - Returns:
- Success:
true - Failure:
nil, "model invalid"
- Success:
- Purpose: Marks the current model active and begins printing up to the requested number of copies over time.
Parameters:
count:numberoptional: number of copies to queue. Defaults to1.
Behavior:
- The model must have at least one
stateOffshape. - Both shape sets must stay within the configured complexity limit.
count <= 0effectively disables further printing by leavingisActivefalse.
- Syntax:
printer.status() - Returns:
- While printing:
"busy", progress - Idle with valid model:
"idle", true - Idle with invalid model:
"idle", false
- While printing:
- Purpose: Reports printer state and either progress or model validity.
Behavior:
progressis a percentage from0to100.
printer.reset()
printer.setLabel("Status Block")
printer.setTooltip("Printed by OC")
printer.setLightLevel(8)
printer.setRedstoneEmitter(15)
printer.setButtonMode(true)
printer.setCollidable(true, true)
assert(printer.addShape(0, 0, 0, 16, 4, 16, "opencomputers:block/print"))
assert(printer.addShape(4, 4, 4, 12, 12, 12, "opencomputers:block/print", true, 0xFF0000))
print("Shapes:", printer.getShapeCount())
assert(printer.commit(1))componentopencomputers-openos-print3d