diff options
author | Pierre-Yves Rollo <dev@pyrollo.com> | 2017-12-28 20:21:56 +0100 |
---|---|---|
committer | Pierre-Yves Rollo <dev@pyrollo.com> | 2017-12-28 20:21:56 +0100 |
commit | 755fba6ce01fdd76d909e95a95d612c5d817b683 (patch) | |
tree | e7c64192dc627854b2f8ce7a4fecfb228e4b9be4 /signs | |
parent | 4268154b6409e70c278f2e6ad2946283ef1310b2 (diff) | |
download | display_modpack-755fba6ce01fdd76d909e95a95d612c5d817b683.tar.gz display_modpack-755fba6ce01fdd76d909e95a95d612c5d817b683.tar.bz2 display_modpack-755fba6ce01fdd76d909e95a95d612c5d817b683.zip |
Added function signs.set_display_text for programmatically changing the sign text.
Diffstat (limited to 'signs')
-rw-r--r-- | signs/common.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/signs/common.lua b/signs/common.lua index 44fd5bf..49c6dd4 100644 --- a/signs/common.lua +++ b/signs/common.lua @@ -21,6 +21,13 @@ local S = signs.intllib local F = function(...) return minetest.formspec_escape(S(...)) end +function signs.set_display_text(pos,text) + local meta = minetest.get_meta(pos) + meta:set_string("display_text", text) + meta:set_string("infotext", "\""..text.."\"") + display_lib.update_entities(pos) +end + function signs.set_formspec(pos) local meta = minetest.get_meta(pos) local ndef = minetest.registered_nodes[minetest.get_node(pos).name] @@ -49,11 +56,8 @@ end function signs.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 or fields.key_enter) then - meta:set_string("display_text", fields.display_text) - meta:set_string("infotext", "\""..fields.display_text.."\"") - display_lib.update_entities(pos) + signs.set_display_text(pos, fields.display_text) end end end |