minetest-mods / woodcutting

GNU Lesser General Public License v3.0
7 stars 8 forks source link

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.

Forum: https://forum.minetest.net/viewtopic.php?f=9&t=18023

Screenshot

Highlights / Features

Develper notes

The mod does have some settings, hooks and an objects style API for game- or other-mods related enhancements.

(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
    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
    wear_limit = 65535,   -- Maximum tool wear that allows cutting
}

Hooks

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

Process object

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.

Attributes

See (default) Settings

Methods

Note:this methods could be redefined in on_new_process_hook, in a different way for each new process