Compare commits

...

2 Commits

Author SHA1 Message Date
teknomunk 922f6c5000 Test entity 2024-05-05 15:56:55 +00:00
teknomunk 2c59a34dbc Create node entity 2024-05-04 09:37:30 +00:00
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,57 @@
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
minetest.register_chatcommand("test-entity-node",{
func = function(name,param)
local center = mod.create_node_entity(vector.new(126,4,68),"mcl_core:dirt")
--[[
local a = mod.create_node_entity(vector.zero(),"mcl_core:dirt_with_grass")
a:set_attach(center, "", vector.new( 10,0, 0))
local a = mod.create_node_entity(vector.zero(),"mcl_core:dirt_with_grass")
a:set_attach(center, "", vector.new(-10,0, 0))
local a = mod.create_node_entity(vector.zero(),"mcl_core:dirt_with_grass")
a:set_attach(center, "", vector.new( 0,0, 10))
local a = mod.create_node_entity(vector.zero(),"mcl_core:dirt_with_grass")
a:set_attach(center, "", vector.new( 0,0,-10))
]]
end
})

View File

@ -0,0 +1,4 @@
name = vl_node_entity
author = teknomunk
description = An entity that duplicates a registered node
depends = mcl_core