| | |
| | | {"moretrees:rubber_tree_leaves", false}, |
| | | } |
| | | |
| | | -- Remember node visited recursive and not dig twice |
| | | local node_visited = {} |
| | | |
| | | local timber_nodenames = {} |
| | | for _, node in pairs(nodes) do |
| | |
| | | |
| | | -- This function checks if the specified node should be sawed |
| | | local function check_if_node_sawed(pos) |
| | | local node_name = minetest.get_node(pos).name |
| | | local node = minetest.get_node(pos) |
| | | local node_name = node.name |
| | | |
| | | |
| | | if timber_nodenames[node_name] |
| | | or (xnotreetap_leaves and minetest.get_item_group(node_name, "leaves") ~= 0) |
| | | or minetest.get_item_group(node_name, "tree") ~= 0 then |
| | | minetest.log("action", "[Xno Tree Tap] "..node_name.." good node to collect.") --print to log |
| | | return true |
| | | end |
| | | |
| | |
| | | end |
| | | end |
| | | |
| | | -- inserisco un valore in tabella |
| | | local function add_table(table, toadd) |
| | | local i = 1 |
| | | while true do |
| | | local o = table[i] |
| | | if o == toadd then return end |
| | | if o == nil then break end |
| | | i = i + 1 |
| | | end |
| | | table[i] = toadd |
| | | end |
| | | |
| | | -- bool controllo se un valore è presente in tabella |
| | | local function in_table(table, value) |
| | | local i = 1 |
| | | while true do |
| | | local o = table[i] |
| | | if o == value then |
| | | minetest.log("action", "[Xno Tree Tap] "..value.." visited.") --print to log |
| | | return true |
| | | end |
| | | if o == nil then break end |
| | | i = i + 1 |
| | | end |
| | | return false |
| | | end |
| | | |
| | | -- verifico se un nodo è nella tabella visitato |
| | | local function check_if_node_visited (pos) |
| | | return in_table(node_visited, pos) |
| | | end |
| | | |
| | | local function myString (v) |
| | | return v.x.." "..v.y.." "..v.z.." " |
| | | end |
| | | |
| | | local function set_node_visited (pos) |
| | | minetest.log("action", "[Xno Tree Tap] "..myString(pos).." set node visited.") --print to log |
| | | |
| | | add_table(node_visited, pos) |
| | | end |
| | | |
| | | -- This function does all the hard work. Recursively we dig the node at hand |
| | | -- if it is in the table and then search the surroundings for more stuff to dig. |
| | |
| | | if remaining_charge < xnotreetap_charge_per_node then |
| | | return remaining_charge |
| | | end |
| | | local node = minetest.get_node(pos) |
| | | |
| | | if check_if_node_visited(pos) then |
| | | return remaining_charge |
| | | end |
| | | |
| | | if not check_if_node_sawed(pos) then |
| | | return remaining_charge |
| | | end |
| | | |
| | | local node = minetest.get_node(pos) |
| | | |
| | | if node.name == "moretrees:rubber_tree_trunk" then |
| | | --raccolta gomma |
| | | node.name = "moretrees:rubber_tree_trunk_empty" |
| | | minetest.swap_node(pos, node) |
| | | -- minetest.handle_node_drops(pointed_thing.above, {"technic:raw_latex"}, user) |
| | | handle_drops({"technic:raw_latex"}) |
| | | handle_drops(minetest.get_node_drops("technic:raw_latex", "")) |
| | | remaining_charge = remaining_charge - xnotreetap_charge_per_node |
| | | |
| | | -- Wood found - cut it |
| | |
| | | -- itemstack:set_wear(item_wear) |
| | | -- end |
| | | end |
| | | |
| | | set_node_visited(pos) |
| | | |
| | | -- Check surroundings and run recursively if any charge left |
| | | for npos in iterSawTries(pos) do |
| | |
| | | -- end |
| | | -- end |
| | | --}) |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |