+local
+minetest,vector,table,pairs,type,math
+=
+minetest,vector,table,pairs,type,math
--
-- Falling entity ("rewrite"")
--
+local param_translation = {
+ [0] = 0,
+ [3] = math.pi/2,
+ [2] = math.pi,
+ [1] = math.pi*1.5,
+}
+
+
+
minetest.register_entity(":__builtin:falling_node", {
initial_properties = {
visual = "wielditem",
end
end
self.meta = meta
+
+
self.object:set_properties({
is_visible = true,
textures = {node.name},
})
+
+ if node.param2 then
+ self.object:set_rotation(vector.new(0,param_translation[node.param2],0))
+ end
end,
get_staticdata = function(self)
-- If it's not air or liquid, remove node and replace it with
-- it's drops
if n2.name ~= "air" and (not nd or nd.liquidtype == "none") then
- minetest.remove_node(np)
- if nd and nd.buildable_to == false then
- -- Add dropped items
- local drops = minetest.get_node_drops(n2, "")
- for _, dropped_item in pairs(drops) do
- minetest.add_item(np, dropped_item)
+ local drops = minetest.get_node_drops(self.node.name, "")
+ if drops and table.getn(drops) > 0 then
+ for _,droppy in pairs(drops) do
+ minetest.throw_item(np,droppy)
end
+ else
+ minetest.throw_item(np,self.node)
end
- -- Run script hook
- for _, callback in pairs(minetest.registered_on_dignodes) do
- callback(np, n2)
- end
+ self.object:remove()
+ return
end
-- Create node and remove entity
local def = minetest.registered_nodes[self.node.name]
minetest.check_for_falling(np)
return
end
+
local vel = self.object:get_velocity()
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
local npos = self.object:get_pos()