aboutsummaryrefslogtreecommitdiff
path: root/display_lib/init.lua
diff options
context:
space:
mode:
authorPierre-Yves Rollo <dev@pyrollo.com>2017-08-26 14:12:38 +0200
committerPierre-Yves Rollo <dev@pyrollo.com>2017-08-26 14:12:38 +0200
commitc179f44ba481c73158fa72d658cbd9fed046dcdd (patch)
tree48513ec25683841fad77f51a48ce91f0f47deaf9 /display_lib/init.lua
parentd59c475162da02695a85ebd92a44e53129aa8be3 (diff)
downloaddisplay_modpack-c179f44ba481c73158fa72d658cbd9fed046dcdd.tar.gz
display_modpack-c179f44ba481c73158fa72d658cbd9fed046dcdd.tar.bz2
display_modpack-c179f44ba481c73158fa72d658cbd9fed046dcdd.zip
Release 2017-08-26
Diffstat (limited to 'display_lib/init.lua')
-rw-r--r--display_lib/init.lua29
1 files changed, 16 insertions, 13 deletions
diff --git a/display_lib/init.lua b/display_lib/init.lua
index 63ce99c..4416928 100644
--- a/display_lib/init.lua
+++ b/display_lib/init.lua
@@ -114,7 +114,6 @@ local function place_entities(pos)
local depth = clip_pos_prop(props.depth)
local height = clip_pos_prop(props.height)
local right = clip_pos_prop(props.right)
-
if not objrefs[entity_name] then
objrefs[entity_name] = minetest.add_entity(pos, entity_name)
end
@@ -158,26 +157,30 @@ end
--- On_place callback for display_lib items. Does nothing more than preventing item
--- from being placed on ceiling or ground
function display_lib.on_place(itemstack, placer, pointed_thing)
- local ndef = minetest.registered_nodes[itemstack.name]
+ local ndef = itemstack:get_definition()
local above = pointed_thing.above
local under = pointed_thing.under
local dir = {x = under.x - above.x,
y = under.y - above.y,
z = under.z - above.z}
- if ndef and ndef.paramtype2 == "wallmounted" then
- local wdir = minetest.dir_to_wallmounted(dir)
+ if ndef then
+ if ndef.paramtype2 == "wallmounted" then
- if wdir == 0 or wdir == 1 then
- dir = placer:get_look_dir()
- dir.y = 0
- wdir = minetest.dir_to_wallmounted(dir)
- end
+ local wdir = minetest.dir_to_wallmounted(dir)
- return minetest.item_place(itemstack, placer, pointed_thing, wdir)
- else
- return minetest.item_place(itemstack, placer, pointed_thing)
+ if wdir == 0 or wdir == 1 then
+ dir = placer:get_look_dir()
+ dir.y = 0
+ wdir = minetest.dir_to_wallmounted(dir)
+ end
+
+ return minetest.item_place(itemstack, placer, pointed_thing, wdir)
+ else
+ return minetest.item_place(itemstack, placer, pointed_thing, minetest.dir_to_facedir(dir))
+ end
end
+
end
--- On_construct callback for display_lib items. Creates entities and update them.
@@ -196,7 +199,7 @@ end
-- On_rotate (screwdriver) callback for display_lib items. Prevents axis rotation and reorients entities.
function display_lib.on_rotate(pos, node, user, mode, new_param2)
- if mode ~= screwdriver.ROTATE_FACE then return false end
+ if mode ~= 1 then return false end
local values = get_values(node)