minetest.register_entity

From Minetest Developer Wiki
Jump to navigation Jump to search
Mbox warning.png This page contains unofficial Lua API documentation and is likely to be outdated or wrong.
For the official and up-to-date documentation, refer to lua_api.txt found in your Minetest installation directory under doc.
Mbox warning.png This page has been proposed for deletion for the following reason: "Contains unofficial and potentially outdated, redundant and inconsistent Lua API information"
If you don't think that this page should be deleted, please explain why on the talk page.
Mbox important.png This article is incomplete.
Please help expand this article to include more useful information.
Mbox information.png This article is missing examples.
Feel free to add them.


Syntax

<source>minetest.register_entity(entity_name, entity_definition)</source>

  • entity_name — The registered name of the entity, used as the hash key for <source enclose="none">minetest.regsitered_entities</source> and as the name property of each instantiated LuaEntity.
  • entity_definition — A table of LuaEntity properties.

Description

Registers a LuaEntity that can be spawned as a LuaEntitySAO using <source enclose="none">minetest.add_entity(...)</source>.

Object property table

<source> {

   hp_max = 1,
   physical = true,
   weight = 5,
   collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
   visual = "cube"/"sprite"/"upright_sprite"/"mesh"/"wielditem",
   visual_size = {x=1, y=1},
   mesh = "model",
   textures = {}, -- number of required textures depends on visual
   colors = {}, -- number of required colors depends on visual
   spritediv = {x=1, y=1},
   initial_sprite_basepos = {x=0, y=0},
   is_visible = true,
   makes_footstep_sound = false,
   automatic_rotate = false,

} </source>