From 2fc283a42a8c982d0b5e4b7d4b9ce8b45616ff98 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 4 May 2024 09:37:30 +0000 Subject: [PATCH] Create node entity --- mods/ENTITIES/vl_node_entity/init.lua | 38 +++++++++++++++++++++++++++ mods/ENTITIES/vl_node_entity/mod.conf | 4 +++ 2 files changed, 42 insertions(+) create mode 100644 mods/ENTITIES/vl_node_entity/init.lua create mode 100644 mods/ENTITIES/vl_node_entity/mod.conf diff --git a/mods/ENTITIES/vl_node_entity/init.lua b/mods/ENTITIES/vl_node_entity/init.lua new file mode 100644 index 000000000..b0ca52748 --- /dev/null +++ b/mods/ENTITIES/vl_node_entity/init.lua @@ -0,0 +1,38 @@ +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +vl_node_entity = {} +local mod = vl_node_entity + +local cube_node_entity = { + initial_properties = { + hp_max = 1, + physical = true, + pointable = false, + collide_with_objects = true, + collision_box = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }, + }, + visual = "wielditem", + textures = { "mcl_core:dirt_with_grass" }, +} +function cube_node_entity:on_activate(staticdata, dtime_unloaded) + local staticdata = minetest.deserialize(staticdata) + self._staticdata = staticdata + + local props = { + visual = "wielditem", + textures = { staticdata.nodename }, + } + self.object:set_properties(props) +end +function cube_node_entity:get_staticdata() + return minetest.serialize(self._staticdata) +end +minetest.register_entity("vl_node_entity:cube_node", cube_node_entity) + +function mod.create_node_entity(pos, nodename) + local staticdata = { + nodename = nodename + } + return minetest.add_entity(pos, "vl_node_entity:cube_node",minetest.serialize(staticdata)) +end + diff --git a/mods/ENTITIES/vl_node_entity/mod.conf b/mods/ENTITIES/vl_node_entity/mod.conf new file mode 100644 index 000000000..92c06b5de --- /dev/null +++ b/mods/ENTITIES/vl_node_entity/mod.conf @@ -0,0 +1,4 @@ +name = vl_node_entity +author = teknomunk +description = An entity that duplicates a registered node +depends = mcl_core