added dig_leaves bool setting
This commit is contained in:
parent
b3bafe2265
commit
4fbbce5fde
@ -24,9 +24,10 @@ The mod does have some settings, hooks and an objects style API for game- or oth
|
||||
### (default) Settings
|
||||
```
|
||||
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
|
||||
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
|
||||
|
29
init.lua
29
init.lua
@ -1,15 +1,22 @@
|
||||
woodcutting = {}
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
process:process_leaves(pos)
|
||||
if process.dig_leaves then
|
||||
process:process_leaves(pos)
|
||||
end
|
||||
end)
|
||||
|
||||
----------------------------
|
||||
|
3
settingtypes.txt
Normal file
3
settingtypes.txt
Normal file
@ -0,0 +1,3 @@
|
||||
# If enabled the woodcutting dig not connected leaves
|
||||
# after tree nodes removed
|
||||
woodcutting_dig_leaves (Dig leaves) bool true
|
Loading…
x
Reference in New Issue
Block a user