BlockLogic

BlockLogic

class

Runtime state of a placed block

  • read-only Assigning to the field raises an error.

Fields

NameTypeDescription
map_register boolean Whether this block shows up on the map
static_block StaticBlock Prototype this block was spawned from
pos read-only Vec3i Cell this block stands in
quat read-only FQuat Rotation turning the block's local sides into world sides
state read-only integer State shown under the crosshair, one of defines.block_state
settings read-only table Settings of the block as its window and the save hold them, a fresh copy on every read
inventories read-only table<string, InventoryReader> Inventories the block saves, by name, each as its own class

Functions

BlockLogic:reg(accessor)

Register Accessor

accessor Accessor Accessor instance to register

BlockLogic:find_accessor(name)

Find a registered accessor by name

name string Accessor name

returns Accessor

BlockLogic:accessors()

Every accessor registered on this block

returns Accessor[] Registered accessors

BlockLogic:component(name)

Fields of one of the block's components, a fresh copy on every read

name string Component name, as StaticBlock.components lists it

returns table Field name to value; an item field holds the item or nil

BlockLogic:set_component(name, fields)

Change fields of one of the block's components: the fields given change, the rest keep their values; an item field takes the item, its name or nil

name string Component name
fields table Field name to new value

BlockLogic:get_field(name, field)

One field of one of the block's components

name string Component name
field string Field name

BlockLogic:set_field(name, field, value)

Change one field of one of the block's components

name string Component name
field string Field name
value any New value; an item field takes the item, its name or nil

BlockLogic:edit_settings(fields)

Change settings the way the block's window does: only the fields given change, a prototype stands for its name. The edit goes out to the other peers and lands at the host's stamped tick, so read settings back a tick later

fields table Fields to change, in the shape settings reads; a table keyed 1..n goes as a list, so key a map by strings
Standard members (4)

These members are available on all classes of this kind.

BlockLogic.cast(object) Trying to cast Object into BlockLogic
BlockLogic.get_class() Return BlockLogic class object
BlockLogic.new(parent, name) Creates a new BlockLogic instance
BlockLogic.new_simple() Creates a new BlockLogic instance
Inherited from Instance (1)
Inherited from Object (3)

Subclasses

Used by