From f207040b21faf5a115e25c9c156b59da7553c513 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Thu, 4 Jun 2020 16:19:57 +0200 Subject: [PATCH] rename region --- chatcommands.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/chatcommands.lua b/chatcommands.lua index 2cf0f72..86017cd 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -77,3 +77,31 @@ minetest.register_chatcommand("creative_region_rm", { return true, "Done." end, }) + +minetest.register_chatcommand("creative_region_rn", { + params = ", ", + description = "Rename a creative region", + privs = {server = true}, + func = function(name, param) + local player = minetest.get_player_by_name(name) + if not player then + return false, "Player not found" + end + local found, _, region_id, region_name = param:find("^(r%d+)%s*,%s*(.+)$") + if not found or not region_id or not region_name then + return false, "Syntax error" + end + local astore_id = tonumber(string.sub(region_id, 2)) + local astore_area = creative_regions.astore:get_area(astore_id, false, true) + if astore_area then + astore_area.data = tostring(region_name) + minetest.chat_send_player(name, "[creative_regions] Region " .. region_id .. "updated") + creative_regions.save_regions() + else + minetest.chat_send_player(name, "Failed to update region " .. region_id) + return false, "Region not found" + end + + return true, "Done." + end, +})