From b2663d0ae32e906c53b73bf6aafb77df76e32f56 Mon Sep 17 00:00:00 2001 From: Splizard Date: Mon, 9 Jun 2014 13:30:08 +1200 Subject: [PATCH] Fix a bug when trying to place snow on an unknown node. --- init.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 916c230..eee1262 100644 --- a/init.lua +++ b/init.lua @@ -81,9 +81,11 @@ end --This function places snow checking at the same time for snow level and increasing as needed. --This also takes into account sourrounding snow and makes snow even. function snow.place(pos) - local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}) - local node = minetest.get_node(pos) - local drawtype = minetest.registered_nodes[node.name].drawtype + local node = minetest.get_node_or_nil(pos) + local drawtype = "" + if node and minetest.registered_nodes[node.name] then + drawtype = minetest.registered_nodes[node.name].drawtype + end local bnode = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) if node.name == "default:snow" and minetest.get_node_level(pos) < 63 then @@ -124,7 +126,10 @@ snow.is_uneven = function(pos) for z=-1,1 do local node = get_node({x=pos.x+x,y=pos.y,z=pos.z+z}) local bnode = get_node({x=pos.x+x,y=pos.y-1,z=pos.z+z}) - local drawtype = minetest.registered_nodes[node.name].drawtype + local drawtype + if node and minetest.registered_nodes[node.name] then + drawtype = minetest.registered_nodes[node.name].drawtype + end if drawtype == "plantlike" then if bnode.name == "default:dirt_with_grass" then