From c179f44ba481c73158fa72d658cbd9fed046dcdd Mon Sep 17 00:00:00 2001 From: Pierre-Yves Rollo Date: Sat, 26 Aug 2017 14:12:38 +0200 Subject: Release 2017-08-26 --- display_lib/README.md | 5 ++++- display_lib/copyright.txt | 2 ++ display_lib/init.lua | 29 ++++++++++++++++------------- 3 files changed, 22 insertions(+), 14 deletions(-) create mode 100644 display_lib/copyright.txt (limited to 'display_lib') diff --git a/display_lib/README.md b/display_lib/README.md index d7372d7..3f8571a 100644 --- a/display_lib/README.md +++ b/display_lib/README.md @@ -8,4 +8,7 @@ This library's purpose is to ease creation of nodes with one or more displays on **License**: LPGL -**API**: See API.md document please. +**API**: See [API.md](https://github.com/pyrollo/display_modpack/blob/master/display_lib/API.md) document please. + +For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?f=11&t=13563) at the Minetest forums. + diff --git a/display_lib/copyright.txt b/display_lib/copyright.txt new file mode 100644 index 0000000..5d4adad --- /dev/null +++ b/display_lib/copyright.txt @@ -0,0 +1,2 @@ +Code by Pierre-Yves Rollo (pyrollo) + 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) -- cgit v1.2.3