From cb3b84b8464dca4f7c20ff747b1dd0eee502d533 Mon Sep 17 00:00:00 2001 From: Sirrobzeroone <44497598+sirrobzeroone@users.noreply.github.com> Date: Mon, 22 Mar 2021 17:31:55 +1100 Subject: [PATCH] Moretrees support added back Code cleanup --- i_register_schematic_trees.lua | 254 +++++++++--------- i_register_tree_element_entity.lua | 124 +++++++++ i_tree_config_moretrees.lua | 401 +++++++++++++++-------------- init.lua | 213 ++++----------- mod.conf | 2 +- 5 files changed, 511 insertions(+), 483 deletions(-) create mode 100644 i_register_tree_element_entity.lua diff --git a/i_register_schematic_trees.lua b/i_register_schematic_trees.lua index 825f2c8..68c4af7 100644 --- a/i_register_schematic_trees.lua +++ b/i_register_schematic_trees.lua @@ -6,112 +6,126 @@ local schem_table= {} y = 0 -for dec_name,defs in pairs(minetest.registered_decorations) do +--[[for dec_name,defs in pairs(minetest.registered_decorations) do if string.find(dec_name, "tree") then - minetest.debug(dec_name) + minetest.debug("just name: "..dec_name) end -end +end]]-- for dec_name,defs in pairs(minetest.registered_decorations) do - if string.find(dec_name, "tree") then + if string.find(dec_name, "tree") and not string.find(dec_name, "sapling") then local d_name -- Decoration name local size -- Schematic dimensions, standard pos format eg (x=5,y=12,z=5) local leaves = {} -- Table to store leaf node names local fruit = {} -- Table to store fruit/atatched node names local trunk = "" local schematic - --minetest.debug(dec_name) + local schem_filepath = defs.schematic -- file path to schematic mts binary file if type(schem_filepath) == "table" then -- some schematics stored as lua tables - schematic = schem_filepath + schematic = schem_filepath else schematic = minetest.read_schematic(schem_filepath, "all") -- Reads in all probabilities of nodes from .mts file end - size = schematic.size -- stored in standard pos format eg (x=5,y=12,z=5) - d_name = dec_name - local ts = "" -- ts = (t)emporary (s)tring variable - local nt_name -- Node type name used for L, T, A, F - local sc_lay = 1 - schem_table[d_name]={} - local grps = {} - local grp = {} - for i = 1,#schematic.data do -- Read-in every defined node in schematic - local temp_name = schematic.data[i].name + if schematic ~= nil then + size = schematic.size -- stored in standard pos format eg (x=5,y=12,z=5) + d_name = dec_name + local ts = "" -- ts = (t)emporary (s)tring variable + local nt_name -- Node type name used for L, T, A, F + local sc_lay = 1 + schem_table[d_name]={} + local grps = {} + local grp = {} + + for i = 1,#schematic.data do -- Read-in every defined node in schematic + local temp_name = schematic.data[i].name - if not grp[temp_name] then + if not minetest.registered_nodes[temp_name] then -- Any node not registered treat as air. + temp_name = "air" + end + grps[temp_name] = minetest.registered_nodes[temp_name].groups grp = grps[temp_name] -- Get the groups our current specified schematic node has - else - grp = grps[temp_name] - - end + + --[[old redundant code + if not grp[temp_name] then + + grps[temp_name] = minetest.registered_nodes[temp_name].groups + grp = grps[temp_name] -- Get the groups our current specified schematic node has + else + grp = grps[temp_name] + + end]]-- - if grp.leaves == 1 then -- Check Leaves - nt_name = "L" - leaves[temp_name] = 1 -- Far quicker to set to key, than use a loop + if grp.leaves == 1 then -- Check Leaves + nt_name = "L" + leaves[temp_name] = 1 -- Far quicker to set to key, than use a loop + + elseif grp.tree == 1 then -- Check tree/trunk/log etc + nt_name = "T" + trunk = temp_name - elseif grp.tree == 1 then -- Check tree/trunk/log etc - nt_name = "T" - trunk = temp_name - - elseif string.find(temp_name, "air") then -- Air has no groups so I just use the name check - nt_name = "A" - - else -- If its not one of the three above then for trees it must be fruit/attachments - nt_name = "F" - fruit[temp_name]=1 - end - ------------------------------------------------------------------------------------- - -- The block of code below takes the nt_name and inserts it into schem_table -- - -- However it stores them as each sc_lay = a whole layer as a single string -- - -- formated as: AAAAA/nAAAAA/nAAAAA/nAAAAA/nAAAAA, this allows for debugging and -- - -- is easier to find some settings from than a full table structure. -- - -- This also changes slices from Y vertical slices to X/Z horizontal slices -- - -- The overall "for" loop "i=i, #schematic.data" is moving through the Y slices -- - -- as we process through each Y slice we are actually get the 1st (then 2nd, 3rd..)-- - -- row of each X/z horizontal layer. So code below assembles the XZ slices slowly -- - -- as each Y slice is processed. -- - ------------------------------------------------------------------------------------- - - if i/schematic.size.x ~= math.floor(i/schematic.size.x) then -- if it dosent divide evenly we arent at the end of a row - ts = ts.." "..nt_name - else -- if it divides we are at the end of a row - ts = ts.." "..nt_name -- Add our end value - - if sc_lay < schematic.size.y then -- if sc_lay is less than schematic y size we are still processing that X row through all X layers - if schem_table[d_name][sc_lay] == nil then -- A check do we have any data in this X/Z layer yet - schem_table[d_name][sc_lay] =ts.."\n" -- If not add the data - else - schem_table[d_name][sc_lay] = schem_table[d_name][sc_lay]..ts.."\n" -- If we do then append new row of layer data to existing data - end - ts = "" -- Reset our ts string to blank - sc_lay=sc_lay+1 -- Add one to our layer counter as next row belongs on the next horizontal layer up - else -- Once we are at our last node on our last X layer vertically we write that data and then reset all - if schem_table[d_name][sc_lay] == nil then -- counters as the next lot of data represents next Y slice ie Moving from "Y slice 1" to "Y slice 2" - schem_table[d_name][sc_lay] =ts.."\n" - else - schem_table[d_name][sc_lay] = schem_table[d_name][sc_lay]..ts.."\n" - end - sc_lay = 1 -- reset our layer counter - ts = "" -- naturally blank our temp string + elseif grp.soil == 1 then -- Check for Soil replace with air + nt_name = "A" + + elseif string.find(temp_name, "air") then -- Air has no groups so I just use the name check + nt_name = "A" + + else -- If its not one of the three above then for trees it must be fruit/attachments + nt_name = "F" + fruit[temp_name]=1 end - end - end - schem_table[d_name]["size"] = size -- store the size value for the tree - schem_table[d_name]["leaves"] = leaves -- store leave(s) node name - schem_table[d_name]["fruit"] = fruit -- store fruit(s) node name - schem_table[d_name]["trunk"] = trunk -- store trunk node name ---[[ - minetest.debug(dump(schem_table[d_name]["leaves"])) -- for debugging assistance - minetest.debug(dump(schem_table[d_name]["fruit"])) - for k,v in ipairs(schem_table[d_name]) do - minetest.debug(d_name.." X/Z Slice: Y= "..k.." of "..schem_table[d_name].size.y) - minetest.debug("\n"..v) - end -]]-- - + ------------------------------------------------------------------------------------- + -- The block of code below takes the nt_name and inserts it into schem_table -- + -- However it stores them as each sc_lay = a whole layer as a single string -- + -- formated as: AAAAA/nAAAAA/nAAAAA/nAAAAA/nAAAAA, this allows for debugging and -- + -- is easier to find some settings from than a full table structure. -- + -- This also changes slices from Y vertical slices to X/Z horizontal slices -- + -- The overall "for" loop "i=i, #schematic.data" is moving through the Y slices -- + -- as we process through each Y slice we are actually get the 1st (then 2nd, 3rd..)-- + -- row of each X/z horizontal layer. So code below assembles the XZ slices slowly -- + -- as each Y slice is processed. -- + ------------------------------------------------------------------------------------- + + if i/schematic.size.x ~= math.floor(i/schematic.size.x) then -- if it dosent divide evenly we arent at the end of a row + ts = ts.." "..nt_name + else -- if it divides we are at the end of a row + ts = ts.." "..nt_name -- Add our end value + + if sc_lay < schematic.size.y then -- if sc_lay is less than schematic y size we are still processing that X row through all X layers + if schem_table[d_name][sc_lay] == nil then -- A check do we have any data in this X/Z layer yet + schem_table[d_name][sc_lay] =ts.."\n" -- If not add the data + else + schem_table[d_name][sc_lay] = schem_table[d_name][sc_lay]..ts.."\n" -- If we do then append new row of layer data to existing data + end + ts = "" -- Reset our ts string to blank + sc_lay=sc_lay+1 -- Add one to our layer counter as next row belongs on the next horizontal layer up + else -- Once we are at our last node on our last X layer vertically we write that data and then reset all + if schem_table[d_name][sc_lay] == nil then -- counters as the next lot of data represents next Y slice ie Moving from "Y slice 1" to "Y slice 2" + schem_table[d_name][sc_lay] =ts.."\n" + else + schem_table[d_name][sc_lay] = schem_table[d_name][sc_lay]..ts.."\n" + end + sc_lay = 1 -- reset our layer counter + ts = "" -- naturally blank our temp string + end + end + end + schem_table[d_name]["size"] = size -- store the size value for the tree + schem_table[d_name]["leaves"] = leaves -- store leave(s) node name + schem_table[d_name]["fruit"] = fruit -- store fruit(s) node name + schem_table[d_name]["trunk"] = trunk -- store trunk node name + --[[ + minetest.debug(dump(schem_table[d_name]["leaves"])) -- for debugging assistance + minetest.debug(dump(schem_table[d_name]["fruit"])) + for k,v in ipairs(schem_table[d_name]) do + minetest.debug(d_name.." X/Z Slice: Y= "..k.." of "..schem_table[d_name].size.y) + minetest.debug("\n"..v) + end + ]]-- + end end end @@ -408,8 +422,8 @@ local th_start = math.ceil(def_str.size.y * 0.25) end ---[[ -- debugging - +-- debugging +--[[ local tree_sum = {[def_str.trunk] = { ["th"] = tree.th, ["tt"] = tree.tt, @@ -432,39 +446,39 @@ local th_start = math.ceil(def_str.size.y * 0.25) end tree_debug = string.gsub(tree_debug, "return", "") - minetest.debug("\n"..def_str.trunk..tree_debug) ]]-- - + minetest.debug("\n"..def_str.trunk..tree_debug) +]]-- ----------------------------------------------------------- -- Check if tree_name and tree.tt are already registered -- -- and either update values or register new record -- ----------------------------------------------------------- - if not tree_config[def_str.trunk] then -- Check if tree top table exists if not create - tree_config[def_str.trunk] = {} + if not falling_tree_capitator.tree_config[def_str.trunk] then -- Check if tree top table exists if not create + falling_tree_capitator.tree_config[def_str.trunk] = {} end - if not tree_config[def_str.trunk][tree.tt] then -- If tree already has a config record we need to check + if not falling_tree_capitator.tree_config[def_str.trunk][tree.tt] then -- If tree already has a config record we need to check - tree_config[def_str.trunk][tree.tt] = {} - tree_config[def_str.trunk][tree.tt]["th"] = tree.th - tree_config[def_str.trunk][tree.tt]["tt"] = tree.tt - tree_config[def_str.trunk][tree.tt]["lv"] = tree.lv - tree_config[def_str.trunk][tree.tt]["lw"] = tree.lw - tree_config[def_str.trunk][tree.tt]["lh"] = tree.lh - tree_config[def_str.trunk][tree.tt]["bx"] = tree.bx - tree_config[def_str.trunk][tree.tt]["bn"] = tree.bn - tree_config[def_str.trunk][tree.tt]["bw"] = tree.bw - tree_config[def_str.trunk][tree.tt]["ft"] = tree.ft - tree_config[def_str.trunk][tree.tt]["fx"] = tree.fx - tree_config[def_str.trunk][tree.tt]["fn"] = tree.fn - tree_config[def_str.trunk][tree.tt]["sp"] = tree.sp + falling_tree_capitator.tree_config[def_str.trunk][tree.tt] = {} + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["th"] = tree.th + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["tt"] = tree.tt + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["lv"] = tree.lv + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["lw"] = tree.lw + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["lh"] = tree.lh + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["bx"] = tree.bx + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["bn"] = tree.bn + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["bw"] = tree.bw + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["ft"] = tree.ft + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["fx"] = tree.fx + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["fn"] = tree.fn + falling_tree_capitator.tree_config[def_str.trunk][tree.tt]["sp"] = tree.sp - --minetest.debug("db: "..dump(tree_config)) + --minetest.debug("db: "..dump(falling_tree_capitator.tree_config)) - elseif tree_config[def_str.trunk][tree.tt] then + elseif falling_tree_capitator.tree_config[def_str.trunk][tree.tt] then - local tree_config_data = tree_config[def_str.trunk][tree.tt] + local tree_config_data = falling_tree_capitator.tree_config[def_str.trunk][tree.tt] for k,v in pairs(tree_config_data) do local rev_tab = {} local fin_tab = {} @@ -506,7 +520,7 @@ local th_start = math.ceil(def_str.size.y * 0.25) end ]]-- - for k,v in pairs(tree_config) do + for k,v in pairs(falling_tree_capitator.tree_config) do minetest.debug(k) @@ -519,19 +533,19 @@ local th_start = math.ceil(def_str.size.y * 0.25) end - tree_config[def_str.trunk..count] = {} - tree_config[def_str.trunk..count]["th"] = tree.th - tree_config[def_str.trunk..count]["tt"] = tree.tt - tree_config[def_str.trunk..count]["lv"] = tree.lv - tree_config[def_str.trunk..count]["lw"] = tree.lw - tree_config[def_str.trunk..count]["lh"] = tree.lh - tree_config[def_str.trunk..count]["bx"] = tree.bx - tree_config[def_str.trunk..count]["bn"] = tree.bn - tree_config[def_str.trunk..count]["bw"] = tree.bw - tree_config[def_str.trunk..count]["ft"] = tree.ft - tree_config[def_str.trunk..count]["fx"] = tree.fx - tree_config[def_str.trunk..count]["fn"] = tree.fn - tree_config[def_str.trunk..count]["sp"] = tree.sp + falling_tree_capitator.tree_config[def_str.trunk..count] = {} + falling_tree_capitator.tree_config[def_str.trunk..count]["th"] = tree.th + falling_tree_capitator.tree_config[def_str.trunk..count]["tt"] = tree.tt + falling_tree_capitator.tree_config[def_str.trunk..count]["lv"] = tree.lv + falling_tree_capitator.tree_config[def_str.trunk..count]["lw"] = tree.lw + falling_tree_capitator.tree_config[def_str.trunk..count]["lh"] = tree.lh + falling_tree_capitator.tree_config[def_str.trunk..count]["bx"] = tree.bx + falling_tree_capitator.tree_config[def_str.trunk..count]["bn"] = tree.bn + falling_tree_capitator.tree_config[def_str.trunk..count]["bw"] = tree.bw + falling_tree_capitator.tree_config[def_str.trunk..count]["ft"] = tree.ft + falling_tree_capitator.tree_config[def_str.trunk..count]["fx"] = tree.fx + falling_tree_capitator.tree_config[def_str.trunk..count]["fn"] = tree.fn + falling_tree_capitator.tree_config[def_str.trunk..count]["sp"] = tree.sp end diff --git a/i_register_tree_element_entity.lua b/i_register_tree_element_entity.lua new file mode 100644 index 0000000..1c26cf9 --- /dev/null +++ b/i_register_tree_element_entity.lua @@ -0,0 +1,124 @@ +---------------------------------------------------- +-- Tree Entity Setup -- +---------------------------------------------------- +minetest.register_entity("falling_tree_capitator:tree_element", { + initial_properties = { + physical = true, + collide_with_objects = false, + pointable = false, + collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, + visual = "wielditem", + textures = {}, + automatic_face_movement_dir = 0.0, + visual_size = {x=falling_tree_capitator.bvav_settings.scaling, y=falling_tree_capitator.bvav_settings.scaling} + }, + + node = {}, + set_node = function(self, node) + self.node = node + local prop = { + is_visible = true, + textures = {node.name}, + visual_size = {x=falling_tree_capitator.bvav_settings.scaling, y=falling_tree_capitator.bvav_settings.scaling} + } + self.object:set_properties(prop) + end, + + get_staticdata = function(self) + return self.node.name + end, + + on_activate = function(self, staticdata) + self.object:set_armor_groups({immortal=1}) + if staticdata then + self:set_node({name=staticdata}) + end + minetest.after(0,function() + + if self.parent ~= nil and self.relative ~= nil then + self.object:set_attach(self.parent, "", {x=self.relative.x,y=self.relative.y,z=self.relative.z}, {x=0,y=0,z=0}) + self.object:set_properties({visual_size = {x=falling_tree_capitator.bvav_settings.scaling*3, y=falling_tree_capitator.bvav_settings.scaling*3}}) + --self.object:set_properties({}) + else + --this fixes issues with scaling + self.object:set_properties({visual_size = {x=falling_tree_capitator.bvav_settings.scaling, y=falling_tree_capitator.bvav_settings.scaling}}) + + end + end) + end, + rotation = vector.new(0,0,0), + + on_step = function(self, dtime) + + if self.rotator and self.rotate_dir then + local current_rot = self.object:get_rotation() + + -- Throw items on ground that made up parts of the tree: + -- logs, leaves, sticks,saplings and fruit/attachments + + if math.abs(current_rot.x) > math.pi/2 or math.abs(current_rot.z) > math.pi/2 then + + -- Create a table of all items that may need throwing as result of the + -- tree being cut down. This includes adding sticks(1/10 leaves) and saplings(1/20 leaves) + -- note The below only throws 1/10 of the actual leaf nodes in the tree. + + local tree_type = self.ttype + local throw_ref_table = {["logs"] = self.logs, + ["leaf"] = falling_tree_capitator.tree_config[self.node.name][tree_type].lv, + ["fruit"] = falling_tree_capitator.tree_config[self.node.name][tree_type].ft} + local throw_parts = {} + local throw_parts2={} + local leaf_total = 0 + + + for k,obj_tab in pairs(throw_ref_table) do + + if type(obj_tab) == "table" then + for k2,name in pairs(obj_tab) do + + if k == "leaf" then + leaf_total = leaf_total + self[name] + throw_parts[name]=self[name]/10 + + else + throw_parts[name]=self[name] + end + + end + + else + throw_parts[self.node.name]=obj_tab + end + end + + throw_parts[falling_tree_capitator.tree_config[self.node.name][tree_type].sp] = leaf_total/20 + throw_parts["default:stick"] = leaf_total/10 + + -- Loop through the above table and use throw_item to distribute the items. + for node_name,node_num in pairs(throw_parts) do + -- "if" misses fruit if the name is set to "0" + if node_name ~= 0 then + for i = 1,node_num do + local pos = self.object:get_pos() + minetest.throw_item(pos,{name=node_name},self.rotate_dir,falling_tree_capitator.tree_config[self.node.name][tree_type].th) + end + end + end + + minetest.sound_play("tree_thud",{pos=self.object:get_pos()}) + self.object:remove() + end + + if self.rotate_dir.x ~= 0 then + current_rot.x = current_rot.x + (dtime/(self.rotate_dir.x*2.82)) + elseif self.rotate_dir.z ~= 0 then + current_rot.z = current_rot.z + (dtime/(self.rotate_dir.z*2.82)) + end + self.object:set_rotation(current_rot) + else + if not self.parent or not self.parent:get_luaentity() then + self.object:remove() + end + end + end +}) \ No newline at end of file diff --git a/i_tree_config_moretrees.lua b/i_tree_config_moretrees.lua index 76ced75..cdd6273 100644 --- a/i_tree_config_moretrees.lua +++ b/i_tree_config_moretrees.lua @@ -12,216 +12,231 @@ -- fn == fruit min below trunk height max -- sp == sapling name -tree_config["moretrees:beech_trunk"] = { - ["th"] = 8, - ["tt"] = "s", - ["lv"] = "moretrees:beech_leaves", - ["lw"] = 4, - ["lh"] = 2, - ["bx"] = 1, - ["bn"] = 2, - ["bw"] = 2, - ["ft"] = 0, - ["fx"] = 0, - ["fn"] = 0, - ["sp"] = "moretrees:beech_sapling" +falling_tree_capitator.tree_config["moretrees:beech_trunk"] = { + s = { + ["th"] = 8, + ["tt"] = "s", + ["lv"] = {"moretrees:beech_leaves"}, + ["lw"] = 4, + ["lh"] = 2, + ["bx"] = 1, + ["bn"] = 2, + ["bw"] = 2, + ["ft"] = {}, + ["fx"] = 0, + ["fn"] = 0, + ["sp"] = "moretrees:beech_sapling" + } } -tree_config["moretrees:apple_tree_trunk"] = { - ["th"] = 8, - ["tt"] = "s", - ["lv"] = "moretrees:apple_tree_leaves", - ["lw"] = 9, - ["lh"] = 2, - ["bx"] = 1, - ["bn"] = 5, - ["bw"] = 7, - ["ft"] = "default:apple", - ["fx"] = 2, - ["fn"] = 6, - ["sp"] = "moretrees:apple_tree_sapling" +falling_tree_capitator.tree_config["moretrees:apple_tree_trunk"] = { + s = { + ["th"] = 8, + ["tt"] = "s", + ["lv"] = {"moretrees:apple_tree_leaves"}, + ["lw"] = 9, + ["lh"] = 2, + ["bx"] = 1, + ["bn"] = 5, + ["bw"] = 7, + ["ft"] = {"default:apple"}, + ["fx"] = 2, + ["fn"] = 6, + ["sp"] = "moretrees:apple_tree_sapling" + } } -tree_config["moretrees:oak_trunk"] = { - ["th"] = 22, - ["tt"] = "x", - ["lv"] = "moretrees:oak_leaves", - ["lw"] = 11, - ["lh"] = 4, - ["bx"] = 2, - ["bn"] = 16, - ["bw"] = 10, - ["ft"] = "moretrees:acorn", - ["fx"] = 1, - ["fn"] = 18, - ["sp"] = "moretrees:oak_sapling" +falling_tree_capitator.tree_config["moretrees:oak_trunk"] = { + x = { + ["th"] = 22, + ["tt"] = "x", + ["lv"] = {"moretrees:oak_leaves"}, + ["lw"] = 11, + ["lh"] = 4, + ["bx"] = 2, + ["bn"] = 16, + ["bw"] = 10, + ["ft"] = {"moretrees:acorn"}, + ["fx"] = 1, + ["fn"] = 18, + ["sp"] = "moretrees:oak_sapling" + } } -tree_config["moretrees:poplar_trunk"] = { - ["th"] = 24, - ["tt"] = "s", - ["lv"] = "moretrees:poplar_leaves", - ["lw"] = 4, - ["lh"] = 4, - ["bx"] = 0, - ["bn"] = 0, - ["bw"] = 0, - ["ft"] = 0, - ["fx"] = 0, - ["fn"] = 0, - ["sp"] = "moretrees:poplar_sapling" +falling_tree_capitator.tree_config["moretrees:poplar_trunk"] = { + s = { + ["th"] = 24, + ["tt"] = "s", + ["lv"] = {"moretrees:poplar_leaves"}, + ["lw"] = 4, + ["lh"] = 4, + ["bx"] = 0, + ["bn"] = 0, + ["bw"] = 0, + ["ft"] = {}, + ["fx"] = 0, + ["fn"] = 0, + ["sp"] = "moretrees:poplar_sapling" + } } -tree_config["moretrees:sequoia_trunk"] = { - ["th"] = 40, - ["tt"] = "x", - ["lv"] = "moretrees:sequoia_leaves", - ["lw"] = 9, - ["lh"] = 4, - ["bx"] = 4, - ["bn"] = 30, - ["bw"] = 8, - ["ft"] = 0, - ["fx"] = 0, - ["fn"] = 0, - ["sp"] = "moretrees:sequoia_sapling" +falling_tree_capitator.tree_config["moretrees:sequoia_trunk"] = { + x = { + ["th"] = 40, + ["tt"] = "x", + ["lv"] = {"moretrees:sequoia_leaves"}, + ["lw"] = 9, + ["lh"] = 4, + ["bx"] = 4, + ["bn"] = 30, + ["bw"] = 8, + ["ft"] = {}, + ["fx"] = 0, + ["fn"] = 0, + ["sp"] = "moretrees:sequoia_sapling" + } } -tree_config["moretrees:birch_trunk"] = { - ["th"] = 19, - ["tt"] = "s", - ["lv"] = "moretrees:birch_leaves", - ["lw"] = 7, - ["lh"] = 5, - ["bx"] = 4, - ["bn"] = 12, - ["bw"] = 5, - ["ft"] = 0, - ["fx"] = 0, - ["fn"] = 0, - ["sp"] = "moretrees:birch_sapling" +falling_tree_capitator.tree_config["moretrees:birch_trunk"] = { + s = { + ["th"] = 19, + ["tt"] = "s", + ["lv"] = {"moretrees:birch_leaves"}, + ["lw"] = 7, + ["lh"] = 5, + ["bx"] = 4, + ["bn"] = 12, + ["bw"] = 5, + ["ft"] = {}, + ["fx"] = 0, + ["fn"] = 0, + ["sp"] = "moretrees:birch_sapling" + } } -tree_config["moretrees:spruce_trunk"] = { - ["th"] = 32, - ["tt"] = "x", - ["lv"] = "moretrees:spruce_leaves", - ["lw"] = 9, - ["lh"] = 2, - ["bx"] = 1, - ["bn"] = 27, - ["bw"] = 6, - ["ft"] = "moretrees:spruce_cone", - ["fx"] = 1, - ["fn"] = 28, - ["sp"] = "moretrees:spruce_sapling" +falling_tree_capitator.tree_config["moretrees:spruce_trunk"] = { + x = { + ["th"] = 32, + ["tt"] = "x", + ["lv"] = {"moretrees:spruce_leaves"}, + ["lw"] = 9, + ["lh"] = 2, + ["bx"] = 1, + ["bn"] = 27, + ["bw"] = 6, + ["ft"] = {"moretrees:spruce_cone"}, + ["fx"] = 1, + ["fn"] = 28, + ["sp"] = "moretrees:spruce_sapling" + } } -tree_config["moretrees:cedar_trunk"] = { - ["th"] = 22, - ["tt"] = "s", - ["lv"] = "moretrees:cedar_leaves", - ["lw"] = 9, - ["lh"] = 4, - ["bx"] = 3, - ["bn"] = 17, - ["bw"] = 7, - ["ft"] = "moretrees:cedar_cone", - ["fx"] = 1, - ["fn"] = 18, - ["sp"] = "moretrees:cedar_sapling" +falling_tree_capitator.tree_config["moretrees:cedar_trunk"] = { + s = { + ["th"] = 22, + ["tt"] = "s", + ["lv"] = {"moretrees:cedar_leaves"}, + ["lw"] = 9, + ["lh"] = 4, + ["bx"] = 3, + ["bn"] = 17, + ["bw"] = 7, + ["ft"] = {"moretrees:cedar_cone"}, + ["fx"] = 1, + ["fn"] = 18, + ["sp"] = "moretrees:cedar_sapling" + } } -tree_config["moretrees:willow_trunk"] = { - ["th"] = 15, - ["tt"] = "x", - ["lv"] = "moretrees:willow_leaves", - ["lw"] = 12, - ["lh"] = 4, - ["bx"] = 3, - ["bn"] = 13, - ["bw"] = 11, - ["ft"] = 0, - ["fx"] = 0, - ["fn"] = 0, - ["sp"] = "moretrees:willow_sapling" +falling_tree_capitator.tree_config["moretrees:willow_trunk"] = { + x = { + ["th"] = 15, + ["tt"] = "x", + ["lv"] = {"moretrees:willow_leaves"}, + ["lw"] = 12, + ["lh"] = 4, + ["bx"] = 3, + ["bn"] = 13, + ["bw"] = 11, + ["ft"] = {}, + ["fx"] = 0, + ["fn"] = 0, + ["sp"] = "moretrees:willow_sapling" + } } -tree_config["moretrees:rubber_tree_trunk"] = { - ["th"] = 10, - ["tt"] = "d", - ["lv"] = "moretrees:rubber_tree_leaves", - ["lw"] = 8, - ["lh"] = 7, - ["bx"] = 6, - ["bn"] = 6, - ["bw"] = 6, - ["ft"] = 0, - ["fx"] = 0, - ["fn"] = 0, - ["sp"] = "moretrees:rubber_tree_sapling" +falling_tree_capitator.tree_config["moretrees:rubber_tree_trunk"] = { + d = { + ["th"] = 10, + ["tt"] = "d", + ["lv"] = {"moretrees:rubber_tree_leaves"}, + ["lw"] = 8, + ["lh"] = 7, + ["bx"] = 6, + ["bn"] = 6, + ["bw"] = 6, + ["ft"] = {}, + ["fx"] = 0, + ["fn"] = 0, + ["sp"] = "moretrees:rubber_tree_sapling" + } } -tree_config["moretrees:jungletree_trunk"] = { - ["th"] = 11, - ["tt"] = "a", - ["lv"] = {"default:jungleleaves","moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_yellow"}, - ["lw"] = 6, - ["lh"] = 1, - ["bx"] = 0, - ["bn"] = 5, - ["bw"] = 3, - ["ft"] = "vines:vine", - ["fx"] = 2, - ["fn"] = 11, - ["sp"] = "moretrees:jungletree_sapling" - } - -tree_config["moretrees:jungletree_trunk_d"] = { - ["th"] = 34, - ["tt"] = "d", - ["lv"] = {"default:jungleleaves","moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_yellow"}, - ["lw"] = 8, - ["lh"] = 2, - ["bx"] = 1, - ["bn"] = 26, - ["bw"] = 6, - ["ft"] = "vines:vine", - ["fx"] = 2, - ["fn"] = 34, - ["sp"] = "moretrees:jungletree_sapling" - } - -tree_config["moretrees:jungletree_trunk_x"] = { - ["th"] = 24, - ["tt"] = "x", - ["lv"] = {"default:jungleleaves","moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_yellow"}, - ["lw"] = 8, - ["lh"] = 2, - ["bx"] = 1, - ["bn"] = 12, - ["bw"] = 6, - ["ft"] = "vines:vine", - ["fx"] = 2, - ["fn"] = 24, - ["sp"] = "moretrees:jungletree_sapling" - } - -tree_config["moretrees:jungletree_trunk_t"] = { - ["th"] = 34, - ["tt"] = "t", - ["lv"] = {"default:jungleleaves","moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_yellow"}, - ["lw"] = 8, - ["lh"] = 2, - ["bx"] = 1, - ["bn"] = 26, - ["bw"] = 6, - ["ft"] = "vines:vine", - ["fx"] = 2, - ["fn"] = 34, - ["sp"] = "moretrees:jungletree_sapling" - } ---tree_config = { --- ["moretrees:palm_trunk"] = {["h"] = 11,["t"] = "a",["w"] = 10,["bx"] = 6,["bn"] = 0, ["bw"] = 4, ["lv"] = "moretrees:palm_leaves" ,["ft"] = 0 ,["ftx"] = 0, ["ftn"] = 0}, --- ["moretrees:fir_trunk"] = {["h"] = 15,["t"] = "s",["w"] = 12,["bx"] = 3,["bn"] = 14,["bw"] = 11,["lv"] = "moretrees:willow_leaves" ,["ft"] = "moretrees:fir_cone" ,["ftx"] = 0, ["ftn"] = 0} --- }"moretrees:rubber_tree_trunk""moretrees:fir_trunk" \ No newline at end of file +falling_tree_capitator.tree_config["moretrees:jungletree_trunk"] = { + s = { + ["th"] = 11, + ["tt"] = "a", + ["lv"] = {"default:jungleleaves","moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_yellow"}, + ["lw"] = 6, + ["lh"] = 1, + ["bx"] = 0, + ["bn"] = 5, + ["bw"] = 3, + ["ft"] = {"vines:vine"}, + ["fx"] = 2, + ["fn"] = 11, + ["sp"] = "moretrees:jungletree_sapling" + }, + d = { + ["th"] = 34, + ["tt"] = "d", + ["lv"] = {"default:jungleleaves","moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_yellow"}, + ["lw"] = 8, + ["lh"] = 2, + ["bx"] = 1, + ["bn"] = 26, + ["bw"] = 6, + ["ft"] = {"vines:vine"}, + ["fx"] = 2, + ["fn"] = 34, + ["sp"] = "moretrees:jungletree_sapling" + }, + x = { + ["th"] = 24, + ["tt"] = "x", + ["lv"] = {"default:jungleleaves","moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_yellow"}, + ["lw"] = 8, + ["lh"] = 2, + ["bx"] = 1, + ["bn"] = 12, + ["bw"] = 6, + ["ft"] = {"vines:vine"}, + ["fx"] = 2, + ["fn"] = 24, + ["sp"] = "moretrees:jungletree_sapling" + }, + t = { + ["th"] = 34, + ["tt"] = "t", + ["lv"] = {"default:jungleleaves","moretrees:jungletree_leaves_red","moretrees:jungletree_leaves_yellow"}, + ["lw"] = 8, + ["lh"] = 2, + ["bx"] = 1, + ["bn"] = 26, + ["bw"] = 6, + ["ft"] = {"vines:vine"}, + ["fx"] = 2, + ["fn"] = 34, + ["sp"] = "moretrees:jungletree_sapling" + } + } \ No newline at end of file diff --git a/init.lua b/init.lua index ef9b53f..8c5263b 100644 --- a/init.lua +++ b/init.lua @@ -20,25 +20,24 @@ local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) local S = minetest.get_translator(modname) +falling_tree_capitator = {} +falling_tree_capitator.tree_config = {} +falling_tree_capitator.bvav_settings = {} +falling_tree_capitator.bvav_settings.attach_scaling = 30 +falling_tree_capitator.bvav_settings.scaling = 0.667 ----------------------------------------------------- -- Tree Config -- ----------------------------------------------------- -tree_config = {} ---dofile(modpath .. "/i_tree_config_default.lua") ---dofile(modpath .. "/i_tree_config_moretrees.lua") +dofile(modpath .. "/i_register_tree_element_entity.lua") dofile(modpath .. "/i_register_schematic_trees.lua") +dofile(modpath .. "/i_tree_config_moretrees.lua") ---minetest.debug("db: "..dump(tree_config)) - ------------------------------------------------------ -bvav_settings = {} -bvav_settings.attach_scaling = 30 -bvav_settings.scaling = 0.667 +--minetest.debug("db: "..dump(falling_tree_capitator.tree_config)) ----------------------------------------------------- -- Tree override on_dig -- ----------------------------------------------------- -for tree_name,def in pairs(tree_config) do +for tree_name,def in pairs(falling_tree_capitator.tree_config) do if minetest.registered_nodes[tree_name] then minetest.override_item(tree_name, { @@ -82,130 +81,6 @@ function minetest.throw_item(pos, item, dir, height) return obj end ----------------------------------------------------- --- Tree Entity Setup -- ----------------------------------------------------- -minetest.register_entity("falling_tree_capitator:tree_element", { - initial_properties = { - physical = true, - collide_with_objects = false, - pointable = false, - collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, - visual = "wielditem", - textures = {}, - automatic_face_movement_dir = 0.0, - visual_size = {x=bvav_settings.scaling, y=bvav_settings.scaling} - }, - - node = {}, - - set_node = function(self, node) - self.node = node - local prop = { - is_visible = true, - textures = {node.name}, - visual_size = {x=bvav_settings.scaling, y=bvav_settings.scaling} - } - self.object:set_properties(prop) - end, - - get_staticdata = function(self) - return self.node.name - end, - - on_activate = function(self, staticdata) - self.object:set_armor_groups({immortal=1}) - if staticdata then - self:set_node({name=staticdata}) - end - minetest.after(0,function() - - if self.parent ~= nil and self.relative ~= nil then - self.object:set_attach(self.parent, "", {x=self.relative.x,y=self.relative.y,z=self.relative.z}, {x=0,y=0,z=0}) - self.object:set_properties({visual_size = {x=bvav_settings.scaling*3, y=bvav_settings.scaling*3}}) - --self.object:set_properties({}) - else - --this fixes issues with scaling - self.object:set_properties({visual_size = {x=bvav_settings.scaling, y=bvav_settings.scaling}}) - - end - end) - end, - rotation = vector.new(0,0,0), - on_step = function(self, dtime) - - if self.rotator and self.rotate_dir then - local current_rot = self.object:get_rotation() - - -- Throw items on ground that made up parts of the tree: - -- logs, leaves, sticks,saplings and fruit/attachments - - if math.abs(current_rot.x) > math.pi/2 or math.abs(current_rot.z) > math.pi/2 then - - -- Create a table of all items that may need throwing as result of the - -- tree being cut down. This includes adding sticks(1/10 leaves) and saplings(1/20 leaves) - -- note The below only throws 1/10 of the actual leaf nodes in the tree. - - local tree_type = self.ttype - local throw_ref_table = {["logs"] = self.logs, - ["leaf"] = tree_config[self.node.name][tree_type].lv, - ["fruit"] = tree_config[self.node.name][tree_type].ft} - local throw_parts = {} - local throw_parts2={} - local leaf_total = 0 - - - for k,obj_tab in pairs(throw_ref_table) do - - if type(obj_tab) == "table" then - for k2,name in pairs(obj_tab) do - - if k == "leaf" then - leaf_total = leaf_total + self[name] - throw_parts[name]=self[name]/10 - - else - throw_parts[name]=self[name] - end - - end - - else - throw_parts[self.node.name]=obj_tab - end - end - - throw_parts[tree_config[self.node.name][tree_type].sp] = leaf_total/20 - throw_parts["default:stick"] = leaf_total/10 - - -- Loop through the above table and use throw_item to distribute the items. - for node_name,node_num in pairs(throw_parts) do - -- "if" misses fruit if the name is set to "0" - if node_name ~= 0 then - for i = 1,node_num do - local pos = self.object:get_pos() - minetest.throw_item(pos,{name=node_name},self.rotate_dir,tree_config[self.node.name][tree_type].th) - end - end - end - - minetest.sound_play("tree_thud",{pos=self.object:get_pos()}) - self.object:remove() - end - - if self.rotate_dir.x ~= 0 then - current_rot.x = current_rot.x + (dtime/(self.rotate_dir.x*2.82)) - elseif self.rotate_dir.z ~= 0 then - current_rot.z = current_rot.z + (dtime/(self.rotate_dir.z*2.82)) - end - self.object:set_rotation(current_rot) - else - if not self.parent or not self.parent:get_luaentity() then - self.object:remove() - end - end - end, -}) function spawn_bvav_element(p, node) @@ -346,7 +221,7 @@ it simplifies checks later on. end -- Check from largest trunk size to smallest trunk size - if tree_config[tree_name]["t"] then + if falling_tree_capitator.tree_config[tree_name]["t"] then for k,v in pairs(trp_trk) do if type(cross_arr[v[1]]) =="table" and type(cross_arr[v[2]]) =="table" and @@ -364,7 +239,7 @@ it simplifies checks later on. end end - if type(trunk_pieces) ~= "table" and tree_config[tree_name]["x"] then + if type(trunk_pieces) ~= "table" and falling_tree_capitator.tree_config[tree_name]["x"] then for k,v in pairs(crs_trk) do if type(cross_arr[v[1]]) =="table" and type(cross_arr[v[2]]) =="table" and @@ -377,7 +252,7 @@ it simplifies checks later on. end end - if type(trunk_pieces) ~= "table" and tree_config[tree_name]["d"] then + if type(trunk_pieces) ~= "table" and falling_tree_capitator.tree_config[tree_name]["d"] then for k,v in pairs(dbl_trk) do if type(cross_arr[v[1]]) =="table" and type(cross_arr[v[2]]) =="table" and @@ -394,17 +269,17 @@ it simplifies checks later on. local tree = tree_name - tree_h = tree_config[tree][trunk_pieces.type].th - tree_t = tree_config[tree][trunk_pieces.type].tt - leaf_n = tree_config[tree][trunk_pieces.type].lv - leaf_w = tree_config[tree][trunk_pieces.type].lw - leaf_h = tree_config[tree][trunk_pieces.type].lh - brch_h = tree_config[tree][trunk_pieces.type].bx - brch_l = tree_config[tree][trunk_pieces.type].bn - brch_w = tree_config[tree][trunk_pieces.type].bw - frut_n = tree_config[tree][trunk_pieces.type].ft - frut_h = tree_config[tree][trunk_pieces.type].fx - frut_l = tree_config[tree][trunk_pieces.type].fn + tree_h = falling_tree_capitator.tree_config[tree][trunk_pieces.type].th + tree_t = falling_tree_capitator.tree_config[tree][trunk_pieces.type].tt + leaf_n = falling_tree_capitator.tree_config[tree][trunk_pieces.type].lv + leaf_w = falling_tree_capitator.tree_config[tree][trunk_pieces.type].lw + leaf_h = falling_tree_capitator.tree_config[tree][trunk_pieces.type].lh + brch_h = falling_tree_capitator.tree_config[tree][trunk_pieces.type].bx + brch_l = falling_tree_capitator.tree_config[tree][trunk_pieces.type].bn + brch_w = falling_tree_capitator.tree_config[tree][trunk_pieces.type].bw + frut_n = falling_tree_capitator.tree_config[tree][trunk_pieces.type].ft + frut_h = falling_tree_capitator.tree_config[tree][trunk_pieces.type].fx + frut_l = falling_tree_capitator.tree_config[tree][trunk_pieces.type].fn -- write related node positions to all nodes meta plus tree trunk type, -- skip ["type"] field using ipairs as not a position @@ -422,17 +297,17 @@ it simplifies checks later on. local rel_pos2 = minetest.deserialize(temp_p_t) local tree = tree_name - tree_h = tree_config[tree][rel_pos2.type].th - tree_t = tree_config[tree][rel_pos2.type].tt - leaf_n = tree_config[tree][rel_pos2.type].lv - leaf_w = tree_config[tree][rel_pos2.type].lw - leaf_h = tree_config[tree][rel_pos2.type].lh - brch_h = tree_config[tree][rel_pos2.type].bx - brch_l = tree_config[tree][rel_pos2.type].bn - brch_w = tree_config[tree][rel_pos2.type].bw - frut_n = tree_config[tree][rel_pos2.type].ft - frut_h = tree_config[tree][rel_pos2.type].fx - frut_l = tree_config[tree][rel_pos2.type].fn + tree_h = falling_tree_capitator.tree_config[tree][rel_pos2.type].th + tree_t = falling_tree_capitator.tree_config[tree][rel_pos2.type].tt + leaf_n = falling_tree_capitator.tree_config[tree][rel_pos2.type].lv + leaf_w = falling_tree_capitator.tree_config[tree][rel_pos2.type].lw + leaf_h = falling_tree_capitator.tree_config[tree][rel_pos2.type].lh + brch_h = falling_tree_capitator.tree_config[tree][rel_pos2.type].bx + brch_l = falling_tree_capitator.tree_config[tree][rel_pos2.type].bn + brch_w = falling_tree_capitator.tree_config[tree][rel_pos2.type].bw + frut_n = falling_tree_capitator.tree_config[tree][rel_pos2.type].ft + frut_h = falling_tree_capitator.tree_config[tree][rel_pos2.type].fx + frut_l = falling_tree_capitator.tree_config[tree][rel_pos2.type].fn end -- name @@ -614,11 +489,11 @@ it simplifies checks later on. else local child = spawn_bvav_element(npos_t, {name=tree_name}) child:get_luaentity().parent = parent - child:get_luaentity().relative = {x=(npos_t.x - t_cent.x )* bvav_settings.attach_scaling, - y=y * bvav_settings.attach_scaling, - z=(npos_t.z-t_cent.z)* bvav_settings.attach_scaling} + child:get_luaentity().relative = {x=(npos_t.x - t_cent.x )* falling_tree_capitator.bvav_settings.attach_scaling, + y=y * falling_tree_capitator.bvav_settings.attach_scaling, + z=(npos_t.z-t_cent.z)* falling_tree_capitator.bvav_settings.attach_scaling} child:set_attach(parent, "", {x=0,y=0,z=0}, {x=0,y=0,z=0}) - child:set_properties({visual_size = {x=bvav_settings.scaling, y=bvav_settings.scaling}}) + child:set_properties({visual_size = {x=falling_tree_capitator.bvav_settings.scaling, y=falling_tree_capitator.bvav_settings.scaling}}) parent:get_luaentity().logs = parent:get_luaentity().logs + 1 end end @@ -649,9 +524,9 @@ it simplifies checks later on. local z = l_pos.z - tp_pos.z local child = spawn_bvav_element(l_pos, {name=v2}) child:get_luaentity().parent = parent - child:get_luaentity().relative = {x=x * bvav_settings.attach_scaling,y=y * bvav_settings.attach_scaling,z=z * bvav_settings.attach_scaling} - child:set_attach(parent, "", {x=x * bvav_settings.attach_scaling,y=y * bvav_settings.attach_scaling,z=z * bvav_settings.attach_scaling}, {x=0,y=0,z=0}) - child:set_properties({visual_size = {x=bvav_settings.scaling, y=bvav_settings.scaling}}) + child:get_luaentity().relative = {x=x * falling_tree_capitator.bvav_settings.attach_scaling,y=y * falling_tree_capitator.bvav_settings.attach_scaling,z=z * falling_tree_capitator.bvav_settings.attach_scaling} + child:set_attach(parent, "", {x=x * falling_tree_capitator.bvav_settings.attach_scaling,y=y * falling_tree_capitator.bvav_settings.attach_scaling,z=z * falling_tree_capitator.bvav_settings.attach_scaling}, {x=0,y=0,z=0}) + child:set_properties({visual_size = {x=falling_tree_capitator.bvav_settings.scaling, y=falling_tree_capitator.bvav_settings.scaling}}) parent:get_luaentity()[v2] = parent:get_luaentity()[v2] + 1 end end @@ -666,9 +541,9 @@ it simplifies checks later on. local z = l_pos.z - tp_pos.z local child = spawn_bvav_element(l_pos, {name=v[1]}) child:get_luaentity().parent = parent - child:get_luaentity().relative = {x=x * bvav_settings.attach_scaling,y=y * bvav_settings.attach_scaling,z=z * bvav_settings.attach_scaling} - child:set_attach(parent, "", {x=x * bvav_settings.attach_scaling,y=y * bvav_settings.attach_scaling,z=z * bvav_settings.attach_scaling}, {x=0,y=0,z=0}) - child:set_properties({visual_size = {x=bvav_settings.scaling, y=bvav_settings.scaling}}) + child:get_luaentity().relative = {x=x * falling_tree_capitator.bvav_settings.attach_scaling,y=y * falling_tree_capitator.bvav_settings.attach_scaling,z=z * falling_tree_capitator.bvav_settings.attach_scaling} + child:set_attach(parent, "", {x=x * falling_tree_capitator.bvav_settings.attach_scaling,y=y * falling_tree_capitator.bvav_settings.attach_scaling,z=z * falling_tree_capitator.bvav_settings.attach_scaling}, {x=0,y=0,z=0}) + child:set_properties({visual_size = {x=falling_tree_capitator.bvav_settings.scaling, y=falling_tree_capitator.bvav_settings.scaling}}) parent:get_luaentity()[k] = parent:get_luaentity()[k] + 1 end end diff --git a/mod.conf b/mod.conf index cb2e7f0..5392e5f 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = falling_tree_capitator depends = default -optional_depends = willow,baldcypress,bamboo,birch,cherrytree,chestnuttree,clementinetree,ebony,hollytree,jacaranda,larch,lemontree,mahogany,maple,oak,palm,pineapple,plumtree,pomegranate,willow +optional_depends = lib_materials,moretrees,willow,baldcypress,bamboo,birch,cherrytree,chestnuttree,clementinetree,ebony,hollytree,jacaranda,larch,lemontree,mahogany,maple,oak,palm,pineapple,plumtree,pomegranate description = Trees fall when cut down with an axe or tool