diff --git a/mods/report/depends.txt b/mods/report/depends.txt index 7df2c284..16a29746 100644 --- a/mods/report/depends.txt +++ b/mods/report/depends.txt @@ -1 +1,2 @@ email +unified_inventory? diff --git a/mods/report/init.lua b/mods/report/init.lua index 3864fb25..49832165 100644 --- a/mods/report/init.lua +++ b/mods/report/init.lua @@ -34,3 +34,49 @@ minetest.register_chatcommand("report", { end end }) + +if minetest.get_modpath("unified_inventory") then + unified_inventory.register_button("report", { + type = "image", + -- From http://www.clker.com/cliparts/v/K/Y/P/2/M/warning-sign-bl-bg-hi.png + image = "report_button.png", + tooltip = "Report to the moderators/administrator", + }) + + unified_inventory.register_page("report", { + get_formspec = function(player) + local form = "field[2,4;5,1;text;Text about what to report:;]" .. + "button[2,5;2,0.5;report;Send]" + return {formspec = form, draw_inventory = false} + end + }) + + minetest.register_on_player_receive_fields(function(player, formname, fields) + if formname ~= "" or not fields.report then + return + end + + -- Copied from src/builtin/game/chatcommands.lua (with little tweaks) + if not fields.text or fields.text == "" then + return + end + local name = player:get_player_name() + local cmd_def = core.chatcommands["report"] + if not cmd_def then + return + end + local has_privs, missing_privs = core.check_player_privs(name, cmd_def.privs) + if has_privs then + core.set_last_run_mod(cmd_def.mod_origin) + local success, message = cmd_def.func(name, fields.text) + if message then + core.chat_send_player(name, message) + end + else + core.chat_send_player(name, "You don't have permission" + .. " to run this command (missing privileges: " + .. table.concat(missing_privs, ", ") .. ")") + end + return true -- Handled fields reception + end) +end diff --git a/mods/report/textures/report_button.png b/mods/report/textures/report_button.png new file mode 100644 index 00000000..379782bf Binary files /dev/null and b/mods/report/textures/report_button.png differ diff --git a/worlds/minetestforfun/random_messages b/worlds/minetestforfun/random_messages index fd9e3e4c..6b6e8865 100755 --- a/worlds/minetestforfun/random_messages +++ b/worlds/minetestforfun/random_messages @@ -22,3 +22,4 @@ Astuce : Vous pouvez rechercher tous les objets d'une classe en tapant le nom de N'hésitez pas à nous envoyer un ticket depuis notre Github si vous voulez que l'on résolve un problème que vous avez découvert ! / Don't hesitate to send us an issue from our Github if you want us to resolve a problem you found! Astuce : Le plus profond vous creuserez, plus vous trouverez de minerais, et plus rares ils seront! / Tip : The deeper you will mine, the more you will find ores, and the more rare they will be! Astuce: Utilisez /guide pour voir le menu "guide du serveur". / Tip: Use /guide to see the server's guide's menu. +Astuce: Utiliser /report pour reporter quelque chose aux modérateurs et à l'administrateur. / Tip : Use /report to report something to the moderators and the administrator.