Don't crash when saplings try to grow on unknown nodes
authory.st <git@y.st>
Mon, 15 Jun 2015 05:51:40 +0000 (22:51 -0700)
committerest31 <MTest31@outlook.com>
Mon, 15 Jun 2015 15:41:25 +0000 (17:41 +0200)
games/minimal/mods/default/init.lua

index 120f004b7ebbbcb3aa9cda223cad0765e4d18ef8..cf0a1c6790972886768a84a8de66554c3c8caf42 100644 (file)
@@ -1660,7 +1660,12 @@ minetest.register_abm({
        interval = 10,
        chance = 50,
        action = function(pos, node)
-               local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
+               local node_under = minetest.registered_nodes[
+                       minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name]
+               if not node_under then
+                       return
+               end
+               local is_soil = node_under.groups.soil
                if is_soil == nil or is_soil == 0 then return end
                print("A sapling grows into a tree at "..minetest.pos_to_string(pos))
                local vm = minetest.get_voxel_manip()