Skip to content

The4codeblocks/luanti_node_entities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Node entity library (nodeentity)

Library for functional node entities, with minimal setup

Node entities should act exactly like normal nodes
any discrepancy should be reported

Namespace reference

nodeentity = {
  function add(pos, node), -- creates a functional node entity at specified position in accordance to specified MapNode table (actually returns an ObjectRef)  
  function read_world(pos, anchor, minp, maxp), -- creates a nodeset at <pos> with nodes from <minp> to <maxp> relative to <anchor>
  function relative_pos(entity), -- given a node luaentity, a position is constructed from which to access the node entity like one'd access normal nodes

  -- exposed internal tables
  fs_context = {
    [formname] = {
      [playername] = {formspec, entity} 
    }
  }, -- table of active forms in nodeentities
}

Position format

local position = {
  x, y, z -- position components
  relative = entityID -- optional relativity specifier; when present, the position is relative to the specified node entity or its corresponding node entity set
}

core/vector namespace functions and ObjectRef/Voxelmanip methods are wrapped to work with these positions
if any of them don't work, make an issue

Node entity sets ("nodeentity:nodeset")

2 node entities attached to the same nodeset share the same pos.relative, and exist at xyz offsets of each-other's positions

To add a node entity to a node set, attach it as specified: nodeobject:set_attach(nodeset, "", pos * 10), the engine requires the pos multiplication, but the automatic inclusion of the entity works as normal

Node definition interface

local nodedef = {
  ...
  function _nodeentity_step(self, dtime, moveresult), -- runs exclusively on node entities, identical to <step> in entity defintions
  <other callbacks> -- current entity is appended to the end of function arguments (abms and lbms included)
  ...
}

Entity fields

local entity = {
  ...
  function _showfs(playername, formname, formspec), -- used like core.show_formspec, includes the nuances in node forms
  _metadata, -- imitation of NodeMetaRef
  _invname, -- inventory name used in showing current node entity inventory
  _timer, -- lua implementation of NodeTimerRef
  ...
}

About

library mod for the Luanti engine allowing creation of non-grid-aligned nodes

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages