@@ -92,21 +92,21 @@ end ::found:: local tposhash = minetest.hash_node_position(tpos) local live, should_cache - local mass_leaves, mass_trunk, topnode, prevalidate + local mass_trunk, topnode, prevalidate if abm_cache.treehash[tposhash] then live = true local c = abm_cache.treehash[tposhash] - mass_leaves = c.mass_leaves + -- mass_leaves = c.mass_leaves mass_trunk = c.mass_trunk prevalidate = true else local tbody live, tbody = sorcery.lib.node.tree_is_live(tpos) if live then should_cache = tbody.nodes[tbody.trunk] - mass_leaves = #(tbody.nodes[tbody.leaves]) + -- mass_leaves = #(tbody.nodes[tbody.leaves]) mass_trunk = #(tbody.nodes[tbody.trunk]) * 12 topnode = tbody.topnode end end @@ -117,22 +117,24 @@ if mass_trunk < 12*3 then return end -- too small tapdrip(tree.sapliq,pos) - local mass = mass_leaves + mass_trunk - local max_mass = 400 - local ltratio = mass_leaves / mass_trunk - local mratio = mass / max_mass - local outof = 15 / mratio - local chance = math.max(1, math.floor(outof - (25 * ltratio))) / 3 - local diceroll = math.random(1,chance) + local mass = mass_trunk -- + mass_leaves + local max_mass = 250 -- 400 + -- local ltratio = mass_leaves / mass_trunk + -- local mratio = mass / max_mass + -- local outof = 15 / mratio + -- local chance = math.max(1, math.floor(outof - (25 * ltratio))) / 3 + local chance = mass / max_mass + local diceroll = math.random(1,math.ceil(chance)) -- log.act('rolling dice: ', chance,diceroll, '(lt ratio =', ltratio, '; mass ratio = ', mratio, '; tree mass =', mass, '; outof =', outof) if diceroll ~= 1 then return end -- failed roll - if not prevalidate then - if minetest.get_natural_light(vector.offset(topnode,0,1,0), 0.5) < 13 - then return false end - end + -- if not prevalidate then + -- if minetest.get_natural_light(vector.offset(topnode,0,1,0), 0.5) < 13 + -- then return false end + -- end + -- FIXME for i=1,8 do local at = vector.offset(pos, 0,-i,0) if sorcery.lib.node.is_air(at) then goto skip end @@ -161,10 +163,10 @@ minetest.swap_node(at, node) end if should_cache then for _,v in pairs(should_cache) do - abm_cache.treehash[v:to_string()] = { - mass_leaves = mass_leaves; + abm_cache.treehash[minetest.hash_node_position(v)] = { + -- mass_leaves = mass_leaves; mass_trunk = mass_trunk; } end end