aboutsummaryrefslogtreecommitdiff
path: root/builtin/common
diff options
context:
space:
mode:
authorDTA7 <dta7e@t-online.de>2017-09-21 21:52:52 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-09-21 21:52:52 +0200
commit5a3b8e34b36a1f9b1f38f91483fc25d23b142f21 (patch)
treee7eaaa6524e6301aa53cde0bb33a35e3305cbaa0 /builtin/common
parent67f97f8d3274e0e96a8f541a05a39f81dfec1a20 (diff)
downloadminetest-5a3b8e34b36a1f9b1f38f91483fc25d23b142f21.tar.gz
minetest-5a3b8e34b36a1f9b1f38f91483fc25d23b142f21.tar.bz2
minetest-5a3b8e34b36a1f9b1f38f91483fc25d23b142f21.zip
Set placer to nil instead of a non-functional one in item_OnPlace (#6449)
* Set placer to nil instead of a non-functional one This requires nil checks in core.rotate_node and core.rotate_and_place.
Diffstat (limited to 'builtin/common')
-rw-r--r--builtin/common/misc_helpers.lua14
1 files changed, 8 insertions, 6 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index 31d335fe2..d7e0b6ae2 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -349,7 +349,7 @@ if INIT == "game" then
itemstack, pointed_thing)
return
end
- local fdir = core.dir_to_facedir(placer:get_look_dir())
+ local fdir = placer and core.dir_to_facedir(placer:get_look_dir()) or 0
local wield_name = itemstack:get_name()
local above = pointed_thing.above
@@ -369,9 +369,9 @@ if INIT == "game" then
iswall = false
end
- if core.is_protected(pos, placer:get_player_name()) then
- core.record_protection_violation(pos,
- placer:get_player_name())
+ local name = placer and placer:get_player_name() or ""
+ if core.is_protected(pos, name) then
+ core.record_protection_violation(pos, name)
return
end
@@ -432,9 +432,11 @@ if INIT == "game" then
end
core.rotate_node = function(itemstack, placer, pointed_thing)
+ local name = placer and placer:get_player_name() or ""
+ local invert_wall = placer and placer:get_player_control().sneak or false
core.rotate_and_place(itemstack, placer, pointed_thing,
- is_creative(placer:get_player_name()),
- {invert_wall = placer:get_player_control().sneak})
+ is_creative(name),
+ {invert_wall = invert_wall})
return itemstack
end
end