Chainsaw: new setting to disable safe cutting

Some trees might generate with param2 != 0, which makes the
chainsaw appear blunt/useless. This safety feature is now
customizable.
This commit is contained in:
SmallJoker 2023-08-26 10:57:03 +02:00
parent 0921c326a8
commit dfcf64c1d0
2 changed files with 11 additions and 1 deletions

9
settingtypes.txt Normal file

@ -0,0 +1,9 @@
# Safety feature for the chainsaw tool aimed to prevent cutting structures
# built by players.
#
# Trunk nodes generated by mapgen have a rotation of '0' whereas manually
# placed trunks usually have another value. However, some mods might generate
# trees with rotation != 0, which renders the chainsaw useless on them.
#
# Disabling this feature will sacrifice safety for convenience.
technic_safe_chainsaw (Chainsaw safety feature) bool true

@ -116,6 +116,7 @@ local cutter = {
-- See function cut_tree()
}
local safe_cut = minetest.settings:get_bool("technic_safe_chainsaw") ~= false
local c_air = minetest.get_content_id("air")
local function dig_recursive(x, y, z)
local i = cutter.area:index(x, y, z)
@ -124,7 +125,7 @@ local function dig_recursive(x, y, z)
end
cutter.seen[i] = 1 -- Mark as visited
if cutter.param2[i] ~= 0 then
if safe_cut and cutter.param2[i] ~= 0 then
-- Do not dig manually placed nodes
-- Problem: moretrees' generated jungle trees use param2 = 2
return