From b270db09606079a62d8d5c19d89b676269673afe Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Wed, 27 May 2020 13:29:46 +0200 Subject: [PATCH] tidy --- chatcommands.lua | 20 +++++++++----------- mod_areas.lua | 4 +++- player.lua | 2 ++ region.lua | 1 - settingtypes.txt | 4 ++-- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/chatcommands.lua b/chatcommands.lua index 6f0f67b..4eaf6df 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -37,17 +37,14 @@ minetest.register_chatcommand("creative_region_privs", { return false, "Player not found" end local found, _, region_id, privstring = param:find("^([+-]?%a?%d+)%s*,%s*(.+)$") - if not found then + if not found or not region_id or not privstring then return false, "Syntax error" end - if privstring and region_id then - creative_regions:set_region_privs(tostring(region_id), privstring) - minetest.chat_send_player(name, "[creative_regions] Privstring set for region " .. region_id .. ": " .. privstring) - creative_regions:save_regions() - return true, "Done" - else - return false, "Failed" - end + + creative_regions:set_region_privs(tostring(region_id), privstring) + minetest.chat_send_player(name, "[creative_regions] Privstring set for region " .. region_id .. ": " .. privstring) + creative_regions:save_regions() + return true, "Done" end, }) @@ -61,7 +58,7 @@ minetest.register_chatcommand("creative_region_rm", { return false, "Player not found" end local found, _, region_id = param:find("^([+-]?%d+)%s*$") - if not found then + if not found or not region_id then return false, "Syntax error" end local success = creative_regions.astore:remove_area(tonumber(region_id)) @@ -69,7 +66,8 @@ minetest.register_chatcommand("creative_region_rm", { minetest.chat_send_player(name, "[creative_regions] Region " .. region_id .. "removed") creative_regions:set_region_privs(tostring(region_id), nil) else - minetest.chat_send_player(name, "[creative_regions] Error removing region " .. region_id) + minetest.chat_send_player(name, "Failed to remove region " .. region_id) + return false, "Region not found" end creative_regions:save_regions() return true, "Done." diff --git a/mod_areas.lua b/mod_areas.lua index 4b8c2e3..1e23c91 100644 --- a/mod_areas.lua +++ b/mod_areas.lua @@ -1,9 +1,11 @@ +--[[ function creative_regions:is_areas_mod(area_id) - area_id = tostring(area_id) + assert(type(area_id) == "string") local is_areas_id = string.sub(id, 1, 2) == "a" local a_id = tonumber( string.sub(id, 2) ) return is_areas_id, a_id end +--]] function creative_regions:get_areas_area_size(areas_area) local pos1 = areas_area.pos1 diff --git a/player.lua b/player.lua index 0a6dc87..cc6ec81 100644 --- a/player.lua +++ b/player.lua @@ -10,6 +10,7 @@ function creative_regions:initial_stuff() return itemtable end +--[[ function creative_regions:save_player_privs(player) local name = player:get_player_name() local pmeta = player:get_meta() @@ -26,6 +27,7 @@ function creative_regions:restore_player_privs(player) pmeta:set_string("creative_regions.saved_privs", nil) end end +--]] function creative_regions:save_player_inventory(player, listname) local name = player:get_player_name() diff --git a/region.lua b/region.lua index 685cdbd..815b50e 100644 --- a/region.lua +++ b/region.lua @@ -56,7 +56,6 @@ function creative_regions:decode_privs_table(privs_table) return privs_grant, privs_revoke end - function creative_regions:add_privs_from_string(privs_table, str) -- minetest/builtin/common/misc_helpers.lua:core.string_to_privs() assert(type(str) == "string") diff --git a/settingtypes.txt b/settingtypes.txt index 8e5834e..55f1dd0 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -5,7 +5,7 @@ creative_regions.owner_privs (Owner privs) string "+creative, +fast, +fly" creative_regions.guest_privs (Guest privs) string "-fly, -fast" # Default privs when not in an area -creative_regions.noregion_privs (Default privs) string "-creative, -fast, -fly" +creative_regions.noregion_privs (Noregion default privs) string "-creative, -fast, -fly" # Default privs for a new area -creative_regions.default_privs (Default privs) string "+creative, +fast, +fly" +creative_regions.default_privs (Region default privs) string "+creative, +fast, +fly"