9607bcc6a6
- Clean up registered_* usage patterns. - Reduce tendancy of leaves to create stack nodes. Now they tend to stack up properly in-world more often. - Tweak damage system to create "headroom" where minor damage doesn't cost inv slots immediately. - Make player hand skin color match model skin. - Cleanup/unify grass abm logic. - Start installing new sounds by MagikEh Sound source: https://github.com/MagikEh/SoundsOfWarr
42 lines
1.2 KiB
Lua
42 lines
1.2 KiB
Lua
-- LUALOCALS < ---------------------------------------------------------
|
|
local ItemStack, ipairs, minetest, nodecore
|
|
= ItemStack, ipairs, minetest, nodecore
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
function nodecore.node_inv(pos)
|
|
return minetest.get_meta(pos):get_inventory()
|
|
end
|
|
|
|
function nodecore.stack_get(pos)
|
|
return nodecore.node_inv(pos):get_stack("solo", 1)
|
|
end
|
|
|
|
local function update(pos, ...)
|
|
for _, v in ipairs(nodecore.visinv_update_ents(pos)) do
|
|
v:get_luaentity():itemcheck()
|
|
end
|
|
return ...
|
|
end
|
|
|
|
function nodecore.stack_set(pos, stack)
|
|
return update(pos, nodecore.node_inv(pos):set_stack("solo", 1, ItemStack(stack)))
|
|
end
|
|
|
|
function nodecore.stack_add(pos, stack)
|
|
local node = minetest.get_node(pos)
|
|
local def = minetest.registered_items[node.name] or {}
|
|
if def.stack_allow then
|
|
local ret = def.stack_allow(pos, node, stack)
|
|
if ret == false then return stack end
|
|
if ret and ret ~= true then return ret end
|
|
end
|
|
return update(pos, nodecore.node_inv(pos):add_item("solo", ItemStack(stack)))
|
|
end
|
|
|
|
function nodecore.stack_giveto(pos, player)
|
|
local stack = nodecore.stack_get(pos)
|
|
stack = player:get_inventory():add_item("main", stack)
|
|
nodecore.stack_set(pos, stack)
|
|
return stack:is_empty()
|
|
end
|