Revise rules for regenerating latex
authorZefram <zefram@fysh.org>
Wed, 13 Aug 2014 22:13:52 +0000 (23:13 +0100)
committerZefram <zefram@fysh.org>
Wed, 13 Aug 2014 22:13:52 +0000 (23:13 +0100)
To ensure that only rubber tree trunk nodes that are part of trees
regenerate, rather than those that are used as building blocks, check
that they are sufficiently close to rubber tree leaves.  This replaces the
older rule that naturally-grown trunks regenerate (regardless of leaves)
and manually-placed trunks don't (even though manually building a tree
otherwise works).  The detection of manually-placed trunks was in any
case broken for users of moretrees, because that mod fails to set the
flag signalling manual placement.

Incidentally also fix a bug that caused rubber tree branches (horizontal
trunk nodes) to turn vertical when regenerating latex.  Rather than set
the complete node structure, only switch the type name, as does the tree
tap when emptying the node.

technic/tools/tree_tap.lua
technic_worldgen/rubber.lua

index 275f4b638a96a4de616dcfdf41e551f20bad92e6..f4b12bf902290f73caa8dfe9acde0c18c05d6483 100644 (file)
@@ -65,11 +65,10 @@ minetest.register_abm({
        interval = 60,
        chance = 15,
        action = function(pos, node)
-               local meta = minetest.get_meta(pos)
-               if meta:get_int("placed") ~= 0 then
-                       return
+               if minetest.find_node_near(pos, (moretrees and moretrees.leafdecay_radius) or 5, {"moretrees:rubber_tree_leaves"}) then
+                       node.name = "moretrees:rubber_tree_trunk"
+                       minetest.swap_node(pos, node)
                end
-               minetest.set_node(pos, {name="moretrees:rubber_tree_trunk"})
        end
 })
 
index f04be84ae7df8eb38b498091ea9be66ec416388a..93b6d663d0f260ccb5245e2760dbdaa5f56e8f29 100644 (file)
@@ -27,10 +27,6 @@ minetest.register_node(":moretrees:rubber_tree_trunk", {
        groups = {tree=1, snappy=1, choppy=2, oddly_breakable_by_hand=1,
                flammable=2},
        sounds = default.node_sound_wood_defaults(),
-       after_place_node = function(pos, placer, itemstack)
-               local meta = minetest.get_meta(pos)
-               meta:set_int("placed", 1)
-       end,
 })
 
 minetest.register_node(":moretrees:rubber_tree_trunk_empty", {
@@ -40,10 +36,6 @@ minetest.register_node(":moretrees:rubber_tree_trunk_empty", {
        groups = {tree=1, snappy=1, choppy=2, oddly_breakable_by_hand=1,
                        flammable=2, not_in_creative_inventory=1},
        sounds = default.node_sound_wood_defaults(),
-       after_place_node = function(pos, placer, itemstack)
-               local meta = minetest.get_meta(pos)
-               meta:set_int("placed", 1)
-       end,
 })
 
 minetest.register_node(":moretrees:rubber_tree_leaves", {