Download (9 KB)
For Luanti 5.14 and above

How do I install this?

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
  ...
}

Reviews

Review

Do you recommend this mod?

  • English

    The create mod should now be theoretically possible

    Seriously an interesting project, there has been similar things in the past and i do hope someone runs with this and makes something cool like a mod where you can build custom vehicles or moving machines,

    2 comments