forked from VoxeLibre/VoxeLibre
Compare commits
2 Commits
master
...
node_entit
Author | SHA1 | Date |
---|---|---|
|
922f6c5000 | |
|
2c59a34dbc |
|
@ -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
|
||||||
|
})
|
|
@ -0,0 +1,4 @@
|
||||||
|
name = vl_node_entity
|
||||||
|
author = teknomunk
|
||||||
|
description = An entity that duplicates a registered node
|
||||||
|
depends = mcl_core
|
Loading…
Reference in New Issue