nodecore-cd2025/mods/nc_items/ent_falling.lua
Aaron Suen b1fab67491 Start work on unifying/simplifying builtins.
falling_node rebuilt from scratch so far.
2020-01-04 10:51:10 -05:00

20 lines
720 B
Lua

-- LUALOCALS < ---------------------------------------------------------
local ItemStack, minetest, nodecore
= ItemStack, minetest, nodecore
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
nodecore.register_falling_node_on_setnode(function(self, node, meta)
if node and node.name == modname .. ":stack"
and meta and meta.inventory and meta.inventory.solo then
local stack = ItemStack(meta.inventory.solo[1] or "")
if not stack:is_empty() then
local ent = minetest.add_item(self.object:get_pos(), stack)
if ent then ent:set_velocity(self.object:get_velocity()) end
self.object:remove()
return true
end
end
end)