aboutsummaryrefslogtreecommitdiff
path: root/display_api/display.lua
diff options
context:
space:
mode:
authorPierre-Yves Rollo <dev@pyrollo.com>2019-03-09 21:18:43 +0100
committerPierre-Yves Rollo <dev@pyrollo.com>2019-03-09 21:18:43 +0100
commit76dde2b6f5831ab56f0a5e3dfaffafdc44352237 (patch)
tree9ef98128e556bbdd8a2570cc0a46f3f09d10f58f /display_api/display.lua
parent7c4af47caf63dc54f9448ac4d0352c0606cf58c4 (diff)
downloaddisplay_modpack_no_craft-76dde2b6f5831ab56f0a5e3dfaffafdc44352237.tar.gz
display_modpack_no_craft-76dde2b6f5831ab56f0a5e3dfaffafdc44352237.zip
Fixed a remaining bug in node placement
Diffstat (limited to 'display_api/display.lua')
-rw-r--r--display_api/display.lua32
1 files changed, 17 insertions, 15 deletions
diff --git a/display_api/display.lua b/display_api/display.lua
index 3fed20a..d241fb3 100644
--- a/display_api/display.lua
+++ b/display_api/display.lua
@@ -226,30 +226,32 @@ end
--- On_place callback for display_api items.
-- Does nothing more than preventing node from being placed on ceiling or ground
--- TODO:When MT<5 is not in use anymore, this should be deprecated
+-- TODO:When MT<5 is not in use anymore, simplify this
function display_api.on_place(itemstack, placer, pointed_thing, override_param2)
- if not display_api.rotation_restriction then
- return minetest.item_place(itemstack, placer, pointed_thing, override_param2)
- end
-
local ndef = itemstack:get_definition()
- local above = pointed_thing.above
- local under = pointed_thing.under
- local dir = {x = under.x - above.x, y = 0, z = under.z - above.z}
+ local dir = {
+ x = pointed_thing.under.x - pointed_thing.above.x,
+ y = pointed_thing.under.y - pointed_thing.above.y,
+ z = pointed_thing.under.z - pointed_thing.above.z,
+ }
- -- If item is not placed on a wall, use the player's view direction instead
- if dir.x == 0 and dir.z == 0 then
- dir = placer:get_look_dir()
+ if display_api.rotation_restriction then
+ -- If item is not placed on a wall, use the player's view direction instead
+ if dir.x == 0 and dir.z == 0 then
+ dir = placer:get_look_dir()
+ end
dir.y = 0
end
local param2 = 0
if ndef then
- local paramtype2 = ndef.paramtype2
- if paramtype2 == "wallmounted" or paramtype2 == "colorwallmounted" then
+ if ndef.paramtype2 == "wallmounted" or
+ ndef.paramtype2 == "colorwallmounted" then
param2 = minetest.dir_to_wallmounted(dir)
- elseif paramtype2 == "facedir" or paramtype2 == "colorfacedir" then
- param2 = minetest.dir_to_facedir(dir)
+
+ elseif ndef.paramtype2 == "facedir" or
+ ndef.paramtype2 == "colorfacedir" then
+ param2 = minetest.dir_to_facedir(dir, not display_api.rotation_restriction)
end
end
return minetest.item_place(itemstack, placer, pointed_thing,