2017-07-05 22:54:00 +02:00
# Woodcutting
This mod is an asynchrounus tree cutter for minetest. Mine the first tree node from a tree while the sneak key is pressed, then wait till the whole tree is breaked down and in your inventory.
2017-07-07 19:41:19 +02:00
Forum: https://forum.minetest.net/viewtopic.php?f=9& t=18023
2017-07-07 19:28:24 +02:00
![Screenshot ](https://github.com/bell07/minetest-woodcutting/raw/master/screenshot.png )
2017-07-05 22:54:00 +02:00
## Highlights / Features
2017-07-07 19:41:19 +02:00
- Lag-free because the work is not done at once. You can observe the woodcutting.
- You can stop the woodcutting by press sneak key second time
2021-05-28 09:09:17 +02:00
- Works with all trees. The cutting just follow connected tree (trunk) blocks in all directions for each cutted node and add them to the processing queue
- You can add additional trees to process by digging other tree nodes manually (without sneak key)
2017-07-07 19:41:19 +02:00
- The distance to the player is used to prefer next node so the player can partially influence the work direction on big areas
- The auto-mining speed is dependent on wielded tool, so the diamond axe is still advantageously than empty hand
- All checks and functionalities are processed (like hunger damage and tool wear) as if the player did the mining manually
2017-07-05 22:54:00 +02:00
- Really nice effect in combination with item_drop mod
2017-07-07 19:41:19 +02:00
- Does work with all trees in Item group "tree" and "leafdecay" leaves and fruits
- Simple HUD message about woodcutting process status if active
- For developers - an enhancement API
2017-07-07 19:03:19 +02:00
2017-07-07 19:23:58 +02:00
## Develper notes
2017-07-07 19:03:19 +02:00
The mod does have some settings, hooks and an objects style API for game- or other-mods related enhancements.
2017-07-07 19:23:58 +02:00
### (default) Settings
2017-07-07 19:03:19 +02:00
```
woodcutting.settings = {
2017-07-24 13:31:21 +02:00
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
2017-07-07 19:03:19 +02:00
player_distance = 80, -- Allow cutting tree nodes with this maximum distance away from player
2017-07-24 13:31:21 +02:00
dig_leaves = true, -- Dig dacayable leaves after tree node is digged - can be changed trough woodcutting_dig_leaves in minetest.conf
2019-08-16 17:44:05 -04:00
wear_limit = 65535, -- Maximum tool wear that allows cutting
2017-07-07 19:03:19 +02:00
}
```
2017-07-07 19:23:58 +02:00
### Hooks
2017-07-07 19:03:19 +02:00
```
woodcutting.settings = {
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
```
2017-07-07 19:23:58 +02:00
### Process object
2017-07-07 19:03:19 +02:00
The hooks get an lua-objects in interface that means a lua-table with functions and setting attributes. The methods could be redefined in on_new_process_hook() function. That means it is possible to use different implemntations by different users at the same time.
2017-07-07 19:23:58 +02:00
#### Attributes
2017-07-07 19:03:19 +02:00
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()
2017-07-24 13:31:21 +02:00
- process.dig_leaves - used at end of on_dignode function - can be adjusted each step in on_after_dig_hook()
2019-08-16 17:44:05 -04:00
- process.wear_limit - used in process:check_processing_allowed(pos) - can be adjusted each step in on_step_hook()
2017-07-07 19:03:19 +02:00
2017-07-07 19:23:58 +02:00
#### Methods
2017-07-07 19:03:19 +02:00
Note:this methods could be redefined in on_new_process_hook, in a different way for each new process
- process:stop_process() - Finish the process
- process:add_tree_neighbors(pos) - Add nearly tree nodes to the processing list
- process:get_delay_time(pos) - Get delay time to dig the node at pos
- process:check_processing_allowed(pos) - Check if tree cut is allowed at pos
- process:select_next_tree_node() - Get the next node from processing list
- process:process_woodcut_step() - Processing step. Should not be redefined - use on_step_hook instead
- process:woodcut_node(pos, delay) - Cut a tree or leaves node - Should not be redefined - on_before_dig_hook instead
- process:process_leaves(pos) - Process leaves around the digged pos
2017-07-07 22:49:49 +02:00
- process:get_hud_message(pos) - Get the HUD message
- process:show_hud(pos) - Create and update players HUD using the get_hud_messgae() method (HUD is disabled in stop_process)