StaticBlock
classPlaceable block prototype
- read-only Assigning to the field raises an error.
- load-only Usable only while mods load. The game seals these members once loading finishes, so a call or a write from a running world raises an error.
Fields
| Name | Type | Description | |
|---|---|---|---|
| logic | Class | BlockLogic class driving the simulation | |
| actor | Class | Presentation actor class spawned for the block | |
| selector | Class | Selector widget class | |
| tesselator | Tesselator | Mesh tesselator used to render the block | |
| sub_blocks | Vec3i[] | Occupied cells relative to the block origin | |
| rotation_locks | Vec3i | Block local axes that keep their world direction; a turn moving a locked axis is refused | |
| replace_tag | string | Blocks sharing a tag replace each other on build | |
| tier | integer | Block tier used for recipe speed scaling | |
| level | integer | Block level within its tier | |
| energy_consumption_per_tick | integer | Energy drawn per simulation tick | |
| energy_production_per_tick | integer | Energy produced per simulation tick | |
| energy_consumption_item | StaticItem | Resource item drawn by this block | |
| energy_production_item | StaticItem | Resource item produced by this block | |
| energy_tooltip | read-only | string | Lines on the power the block draws and produces, as its item tooltip shows them; empty for a block without energy |
| break_effect | Class | Effect actor class spawned when the block is destroyed | |
| lua | table? | Lua prototype table holding logic_init, actor_init and tooltip | |
| logic_init | load-only | function? | Called with the block logic of every new block of this type; makes its inventories and accessors |
| actor_init | load-only | function? | Called with the block actor when it spawns |
| tooltip | load-only | function|string|nil | Tooltip of the block: a string, or a function of the block logic returning one |
| components | load-only | table<string, table> | Components every block of this type keeps: component name to the values a new block starts with; a field left out starts at 0, false, nil or "". Saved with the block and part of the sim state; batch_tick gets them as arrays, BlockLogic.component and get_field read them |
| batch_tick | load-only | function? | Called once every sim tick with all placed blocks of this type, in position order: batch_tick(blocks, components, inventories), or batch_tick(n, components, slots, inventories) from a --!sim chunk. components.<Component>.<field> is the array of that field of every block, read back after the call; --!sim gets integer, boolean and item fields as int64 columns, an item as its sim_id, and no string fields. slots.<inventory> holds item and count columns indexed (i-1)*slots+s, taken before the call. inventories maps an inventory name to the array of that inventory of every block. The tables are kept between ticks and change only when a block of the type comes or goes |
| window | load-only | function? | Builds the window of a block of this type: window(logic) returns the content widget, and may return a function the window calls every frame while it is open |
| half_cover | StaticCover | Cover mesh for the half-height variant | |
| center_cover | StaticCover | Cover mesh for the center part | |
| body_cover | StaticCover | Cover mesh for the block body | |
| export_options | LogicExportOption[] | Logic export signals published by this block type | |
| import_options | LogicImportOption[] | Logic import signals accepted by this block type | |
Functions
StaticBlock:copy(name, spec) load-only
Register a copy of this block under a new name; its item stays the item of the original until block.item is set
| name | string | Name of the new prototype |
| spec | StaticBlock.spec? | Fields set on the copy, as in reg |
returns StaticBlock The copy, nil when the name is taken
Standard members (5)
These members are available on all classes of this kind.
| StaticBlock.cast(object) | Trying to cast Object into StaticBlock |
| StaticBlock.get_class() | Return StaticBlock class object |
| StaticBlock.find(name) | Looks StaticBlock up in db, nil when there is none |
| StaticBlock.get(name) | Takes StaticBlock from db, reports a miss to the log |
| StaticBlock.reg(name, spec) load-only | Register a new StaticBlock static object, or take the registered one of that name |
Inherited from StaticObject (3)
- item Item this object is built from and mined into
- mined_item Item a build pays and mining returns; nil when the object is not minable
- mined_count How many of mined_item a build pays and mining returns; zero when the object is not minable
Inherited from Prototype (2)
- name read-only Object name
- Prototype:is_valid() Returns false once the underlying engine object has been destroyed
Inherited from Object (1)
- Object:get_class() Class of this object
Subclasses
Used by
- BiomeWorldGenerator.underworld_block field
- BlockLogic.static_block field
- Dimension.place param
- Dimension.get_cell return
- GenContext.set_cell param
- GenContext.spawn_block param
- GhostBlockLogic.target field
- OreVeinTarget.replace field
- OreVeinTarget.block field
- StaticItem.block field
- TallSectorData.get_block return
- TallSectorData.set_block param
- ui.thumbnail param