diff options
Diffstat (limited to 'steles')
-rw-r--r-- | steles/README.md | 2 | ||||
-rw-r--r-- | steles/copyright.txt | 8 | ||||
-rw-r--r-- | steles/depends.txt | 4 | ||||
-rw-r--r-- | steles/nodes.lua | 83 |
4 files changed, 53 insertions, 44 deletions
diff --git a/steles/README.md b/steles/README.md index e83a6af..bc14b53 100644 --- a/steles/README.md +++ b/steles/README.md @@ -2,7 +2,7 @@ This mod provides stone steles with text display. Text is locked if area is protected. -For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?f=11&t=13563) at the Minetest forums. +For more information, see the [forum topic](https://forum.minetest.net/viewtopic.php?t=19365) at the Minetest forums. **Dependancies**: default, display\_lib, font\_lib, technic? diff --git a/steles/copyright.txt b/steles/copyright.txt index 63371e7..1a4e167 100644 --- a/steles/copyright.txt +++ b/steles/copyright.txt @@ -1 +1,9 @@ Code by Pierre-Yves Rollo +intllib support (i18n) by (fat115) +intllib fallback code and tools by Diego MartÃnez (kaeza) +Extra contibutors: +(Thomas--S) +Translations: +Muhammad Nur Hidayat Yasuyoshi (MuhdNurHidayat) +(fat115) + diff --git a/steles/depends.txt b/steles/depends.txt index 35625c0..ba43223 100644 --- a/steles/depends.txt +++ b/steles/depends.txt @@ -1,5 +1,5 @@ default intllib? -display_lib -font_lib +display_api +font_api technic? diff --git a/steles/nodes.lua b/steles/nodes.lua index 39eb9ee..79a9ed3 100644 --- a/steles/nodes.lua +++ b/steles/nodes.lua @@ -21,25 +21,16 @@ 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") +display_api.register_display_entity("steles:text") for i, material in ipairs(steles.materials) do local ndef = minetest.registered_nodes[material] if ndef then + local groups = table.copy(ndef.groups) local parts = material:split(":") + groups.display_modpack_node = 1 minetest.register_node("steles:"..parts[2].."_stele", { description = steles.materials_desc[i], @@ -51,43 +42,53 @@ for i, material in ipairs(steles.materials) do node_box = { type = "fixed", fixed = { - {-5/16, -4/16, -2/16, 5/16, 0.5, 2/16}, - {-7/16, -0.5, -4/16, 7/16, -4/16, 4/16} - } + {-5/16, -5/16, -2/16, 5/16, 0.5, 2/16}, + {-7/16, -0.5, -4/16, 7/16, -5/16, 4/16} + }, }, - groups = ndef.groups, + groups = groups, display_entities = { ["steles:text"] = { - on_display_update = font_lib.on_display_update, - depth = -2/16-0.001, height = 2/16, - size = { x = 14/16, y = 12/16 }, - resolution = { x = 144, y = 64 }, + on_display_update = font_api.on_display_update, + depth = -2/16 - display_api.entity_spacing, + top = -2/16, + aspect_ratio = 0.4, + size = { x = 10/16, y = 12/16 }, maxlines = 3, }, }, - on_place = display_lib.on_place, + on_place = function(itemstack, placer, pointed_thing) + minetest.rotate_node(itemstack, placer, pointed_thing) + return display_api.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, - on_destruct = display_lib.on_destruct, - on_rotate = display_lib.on_rotate, + local meta = minetest.get_meta(pos) + meta:set_string("formspec", string.format([=[ + size[6,4]%s%s%s + textarea[0.5,0.7;5.5,2;display_text;%s;${display_text}] + button[1,3;2,1;font;%s] + button_exit[3,3;2,1;ok;%s]]=], + default.gui_bg, default.gui_bg_img, default.gui_slots, + F("Displayed text (3 lines max)"), + F("Font"), F("Write"))) + display_api.on_construct(pos) + end, + on_destruct = display_api.on_destruct, + on_rotate = display_api.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.ok or fields.font then + meta:set_string("display_text", fields.display_text) + meta:set_string("infotext", "\""..fields.display_text.."\"") + display_api.update_entities(pos) + end + if fields.font then + font_api.show_font_list(player, pos) + end + end + end, + on_punch = display_api.update_entities, }) end end |