Make the register_axes function always available

It’s still a no-op if the required setting is disabled, but it removes some strain from the Lua interpreter by being
unconditionally available.
This commit is contained in:
2025-12-09 14:49:03 +01:00
parent 8a2d735aa6
commit a4f537f625
4 changed files with 17 additions and 17 deletions

View File

@@ -95,21 +95,21 @@ function stripped_tree.maybe_strip_trunk(pos, player, tool, wear)
end
-- Function to override axes
if stripped_tree.axes_strip_trees then
function stripped_tree.register_axes(mod_n, axe_types)
for _, axe_name in ipairs(axe_types) do
core.override_item(
mod_n .. ":" .. axe_name, {
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
function stripped_tree.register_axes(mod_n, axe_types)
if stripped_tree.axes_strip_trees ~= true then return end
local pos = pointed_thing.under
for _, axe_name in ipairs(axe_types) do
core.override_item(
mod_n .. ":" .. axe_name, {
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
-- TODO: Add wear to the axe, but it should depend on the material maybe?
stripped_tree.maybe_strip_trunk(pos, user, itemstack)
end,
}
)
end
local pos = pointed_thing.under
-- TODO: Add wear to the axe, but it should depend on the material maybe?
stripped_tree.maybe_strip_trunk(pos, user, itemstack)
end,
}
)
end
end