2018-11-03 18:56:07 -04:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local ItemStack, ipairs, minetest, nodecore
|
2018-11-04 23:30:06 -05:00
|
|
|
= ItemStack, ipairs, minetest, nodecore
|
2018-11-03 18:56:07 -04:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
|
|
|
|
local plank = modname .. ":plank"
|
|
|
|
minetest.register_node(plank, {
|
|
|
|
description = "Wooden Plank",
|
|
|
|
tiles = { modname .. "_plank.png" },
|
|
|
|
groups = {
|
|
|
|
choppy = 3
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-11-03 19:18:28 -04:00
|
|
|
nodecore.extend_node("nc_tree:tree", function(copy, orig)
|
2018-11-04 23:30:06 -05:00
|
|
|
local oc = orig.can_pummel or function() end
|
|
|
|
copy.can_pummel = function(pos, node, stats, ...)
|
|
|
|
if (stats.pointed.above.y - stats.pointed.under.y) ~= 1 then
|
|
|
|
return oc(pos, node, stats)
|
2018-11-03 19:18:28 -04:00
|
|
|
end
|
|
|
|
local wielded = stats.puncher:get_wielded_item()
|
|
|
|
local caps = wielded:get_tool_capabilities()
|
|
|
|
local choppy = caps and caps.groupcaps and caps.groupcaps.choppy
|
|
|
|
if not choppy then
|
2018-11-04 23:30:06 -05:00
|
|
|
return oc(pos, node, stats, ...)
|
|
|
|
end
|
|
|
|
return "plank"
|
|
|
|
end
|
|
|
|
local op = orig.on_pummel or function() end
|
|
|
|
copy.on_pummel = function(pos, node, stats, ...)
|
|
|
|
if stats.check ~= "plank" or stats.duration < 5 then
|
2018-11-03 19:18:28 -04:00
|
|
|
return op(pos, node, stats, ...)
|
|
|
|
end
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
local defer = 0
|
|
|
|
for _, v in ipairs({
|
|
|
|
{x = pos.x + 1, y = pos.y, z = pos.z},
|
|
|
|
{x = pos.x - 1, y = pos.y, z = pos.z},
|
|
|
|
{x = pos.x, y = pos.y, z = pos.z + 1},
|
|
|
|
{x = pos.x, y = pos.y, z = pos.z - 1}
|
|
|
|
}) do
|
|
|
|
if minetest.registered_nodes[minetest.get_node(v)
|
|
|
|
.name].buildable_to then
|
|
|
|
minetest.item_drop(ItemStack(plank), nil, v)
|
|
|
|
else
|
|
|
|
defer = defer + 1
|
2018-11-03 18:56:07 -04:00
|
|
|
end
|
|
|
|
end
|
2018-11-03 19:18:28 -04:00
|
|
|
if defer > 0 then
|
|
|
|
minetest.item_drop(ItemStack(plank .. " " .. defer), nil, pos)
|
|
|
|
end
|
2018-11-03 21:18:39 -04:00
|
|
|
return true
|
2018-11-03 19:18:28 -04:00
|
|
|
end
|
|
|
|
end)
|