placer is not nil, but placer:getpos() is. Ensure that is checked for.

This commit is contained in:
Anthony 2012-07-20 22:17:43 -03:00
parent 1d40e1039f
commit b8dbb5a223
1 changed files with 6 additions and 4 deletions

View File

@ -148,11 +148,13 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
local dir = {x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}
newnode.param2 = minetest.dir_to_wallmounted(dir)
-- Calculate the direction for furnaces and chests and stuff
elseif def.paramtype2 == 'facedir' and placer then
elseif def.paramtype2 == 'facedir' then
local playerpos = placer:getpos()
local dir = {x = pos.x - playerpos.x, y = pos.y - playerpos.y, z = pos.z - playerpos.z}
newnode.param2 = minetest.dir_to_facedir(dir)
minetest.log("action", "facedir: " .. newnode.param2)
if playerpos ~= nil then
local dir = {x = pos.x - playerpos.x, y = pos.y - playerpos.y, z = pos.z - playerpos.z}
newnode.param2 = minetest.dir_to_facedir(dir)
minetest.log("action", "facedir: " .. newnode.param2)
end
end
-- Add node and update