commit 5e5e60a0cf5cb9df7bf791a90f1488c9367b082f Author: sys4-fr Date: Sat Sep 8 14:18:08 2018 +0200 Remplissage du dépôt. diff --git a/init.lua b/init.lua new file mode 100755 index 0000000..cdd01c1 --- /dev/null +++ b/init.lua @@ -0,0 +1,33 @@ + +minetest.register_privilege("notice", "Able to show notices to players.") + +minetest.register_chatcommand("notice", { + params = " ", + privs = { notice=true, }, + description = "Show a notice to a player.", + func = function(name, params) + local target, text = params:match("(%S+)%s+(.+)") + if not (target and text) then + minetest.chat_send_player(name, "Usage: /notice ") + return + end + local player = minetest.get_player_by_name(target) + if not player then + minetest.chat_send_player(name, ("There's no player named '%s'."):format(target)) + return + end + local fs = { } + local y = 0 + for _, line in ipairs(text:split("|")) do + table.insert(fs, ("label[1,%f;%s]"):format(y+1, minetest.formspec_escape(line))) + y = y + 0.5 + end + table.insert(fs, 1, ("size[8,%d]"):format(y+3)) + table.insert(fs, ("button_exit[3,%f;2,0.5;ok;OK]"):format(y+2)) + fs = table.concat(fs) + minetest.chat_send_player(name, "Notice sent.") + minetest.after(0.5, function() + minetest.show_formspec(target, "notice:notice", fs) + end) + end, +})