diff options
author | Pierre-Yves Rollo <dev@pyrollo.com> | 2018-01-18 22:13:15 +0100 |
---|---|---|
committer | Pierre-Yves Rollo <dev@pyrollo.com> | 2018-01-18 22:13:15 +0100 |
commit | 78e3b852740c77b78e19b814e649f66b91dba673 (patch) | |
tree | 0980ead5dfbf8a2ffdfaa95ba8804dbf1769d836 | |
parent | ea36ed50d886677c79ec7ddf056c9815f040835e (diff) | |
download | display_modpack-78e3b852740c77b78e19b814e649f66b91dba673.tar.gz display_modpack-78e3b852740c77b78e19b814e649f66b91dba673.tar.bz2 display_modpack-78e3b852740c77b78e19b814e649f66b91dba673.zip |
Rotation after placement of steles and code style
-rw-r--r-- | steles/nodes.lua | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/steles/nodes.lua b/steles/nodes.lua index 5dba981..7bad5ae 100644 --- a/steles/nodes.lua +++ b/steles/nodes.lua @@ -21,17 +21,6 @@ local S = steles.intllib local F = function(...) return minetest.formspec_escape(S(...)) end -function steles.on_receive_fields(pos, formname, fields, player) - if not minetest.is_protected(pos, player:get_player_name()) then - local meta = minetest.get_meta(pos) - if fields and fields.ok then - meta:set_string("display_text", fields.display_text) - meta:set_string("infotext", "\""..fields.display_text.."\"") - display_lib.update_entities(pos) - end - end -end - display_lib.register_display_entity("steles:text") for i, material in ipairs(steles.materials) do @@ -65,29 +54,33 @@ for i, material in ipairs(steles.materials) do maxlines = 3, }, }, - on_place = display_lib.on_place, + on_place = function(itemstack, placer, pointed_thing) + minetest.rotate_node(itemstack, placer, pointed_thing) + display_lib.on_place(itemstack, placer, pointed_thing) + end, on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", "size[6,4]" - .."textarea[0.5,0.7;5.5,2;display_text;" - ..F("Displayed text (3 lines max)") - ..";${display_text}]" - .."button_exit[2,3;2,1;ok;"..F("Write").."]") - display_lib.on_construct(pos) - end, + local meta = minetest.get_meta(pos) + meta:set_string("formspec", "size[6,4]" + .."textarea[0.5,0.7;5.5,2;display_text;" + ..F("Displayed text (3 lines max)") + ..";${display_text}]" + .."button_exit[2,3;2,1;ok;"..F("Write").."]") + display_lib.on_construct(pos) + end, on_destruct = display_lib.on_destruct, on_rotate = display_lib.on_rotate, on_receive_fields = function(pos, formname, fields, player) - if not minetest.is_protected(pos, player:get_player_name()) then - local meta = minetest.get_meta(pos) - if fields and fields.ok then - meta:set_string("display_text", fields.display_text) - meta:set_string("infotext", "\""..fields.display_text.."\"") - display_lib.update_entities(pos) - end - end - end, - on_punch = function(pos, node, player, pointed_thing) display_lib.update_entities(pos) end, + if not minetest.is_protected(pos, player:get_player_name()) then + local meta = minetest.get_meta(pos) + if fields and fields.ok then + meta:set_string("display_text", fields.display_text) + meta:set_string("infotext", "\""..fields.display_text.."\"") + display_lib.update_entities(pos) + end + end + end, + on_punch = display_lib.update_entities, }) end end + |