added dig_leaves bool setting

This commit is contained in:
Alexander Weber 2017-07-24 13:31:21 +02:00
parent b3bafe2265
commit 4fbbce5fde
3 changed files with 30 additions and 8 deletions

View File

@ -27,6 +27,7 @@ woodcutting.settings = {
tree_distance = 1, -- Apply tree nodes with this distance to the queue. 1 means touching tree nodes only
leaves_distance = 2, -- do not touch leaves around the not removed trees with this distance
player_distance = 80, -- Allow cutting tree nodes with this maximum distance away from player
dig_leaves = true, -- Dig dacayable leaves after tree node is digged - can be changed trough woodcutting_dig_leaves in minetest.conf
}
```
@ -47,6 +48,7 @@ See (default) Settings
- process.tree_distance - used in process:add_tree_neighbors(pos) - can be adjusted each step in on_after_dig_hook()
- process.leaves_distance - used in process:process_leaves(pos) - can be adjusted each step in on_after_dig_hook()
- process.player_distance - used in process:check_processing_allowed(pos) - can be adjusted each step in on_step_hook()
- process.dig_leaves - used at end of on_dignode function - can be adjusted each step in on_after_dig_hook()
#### Methods
Note:this methods could be redefined in on_new_process_hook, in a different way for each new process

View File

@ -4,12 +4,19 @@ woodcutting.settings = {
tree_distance = 1, -- Apply tree nodes with this distance to the queue. 1 means touching tree nodes only
leaves_distance = 2, -- do not touch leaves around the not removed trees with this distance
player_distance = 80, -- Allow cutting tree nodes with this maximum distance away from player
dig_leaves = true, -- Dig dacayable leaves after tree node is digged
on_new_process_hook = function(process) return true end, -- do not start the process if set to nil or return false
on_step_hook = function(process) return true end, -- if false is returned finish the process
on_before_dig_hook = function(process, pos) return true end, -- if false is returned the node is not digged
on_after_dig_hook = function(process, pos, oldnode) return true end, -- if false is returned do nothing after digging node
}
local _woodcutting_dig_leaves = minetest.settings:get_bool("woodcutting_dig_leaves")
if _woodcutting_dig_leaves ~= nil then
woodcutting.settings.dig_leaves = _woodcutting_dig_leaves
end
woodcutting.tree_content_ids = {}
woodcutting.leaves_content_ids = {}
woodcutting.process_runtime = {}
@ -30,6 +37,14 @@ function woodcutting.new_process(playername, template)
process.leaves_distance = process.leaves_distance or woodcutting.settings.leaves_distance
process.player_distance = process.player_distance or woodcutting.settings.player_distance
if process.dig_leaves == nil then --bool value with default value true
if woodcutting.settings.dig_leaves == nil then
process.dig_leaves = false
else
process.dig_leaves = woodcutting.settings.dig_leaves
end
end
local hook = woodcutting.settings.on_new_process_hook(process)
if hook == false then
return
@ -320,7 +335,9 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
process:add_tree_neighbors(pos)
-- process leaves for cutted node
if process.dig_leaves then
process:process_leaves(pos)
end
end)
----------------------------

3
settingtypes.txt Normal file
View File

@ -0,0 +1,3 @@
# If enabled the woodcutting dig not connected leaves
# after tree nodes removed
woodcutting_dig_leaves (Dig leaves) bool true