From 5d74f048c2d087e23810ac2abb767f818fa35603 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Wed, 27 May 2020 14:07:42 +0200 Subject: [PATCH] fix small mistakes --- init.lua | 10 ++++++++-- region.lua | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 05ef7be..b349efe 100644 --- a/init.lua +++ b/init.lua @@ -29,6 +29,7 @@ function creative_regions:update_player(player) local areas_owner = false local areas_guest = false local areas_open = false + local areas_individual_override = false -- skip for players with protection_bypass if minetest.check_player_privs(name, { protection_bypass=true }) then @@ -37,7 +38,7 @@ function creative_regions:update_player(player) -- find active regions local current_regions = self.astore:get_areas_for_pos(pos, true, true) - for astore_id, astore_area in pairs( current_areas ) do + for astore_id, astore_area in pairs( current_regions ) do local id = "r"..tostring(astore_id) local size = creative_regions:get_region_size(astore_area) table.insert(current_regions_size, { ["id"]=id, ["size"]=size }) @@ -71,10 +72,15 @@ function creative_regions:update_player(player) player_active_region_str = player_active_region_str .. "," .. region.id if creative_regions.region_privs[region.id] then creative_regions:add_privs_from_string(new_privs_table, creative_regions.region_privs[region.id]) + if string.sub(region.id, 1, 1) == "a" then + areas_individual_override = true + end elseif string.sub(region.id, 1, 1) == "r" then creative_regions:add_privs_from_string(new_privs_table, default_privs) elseif string.sub(region.id, 1, 1) == "a" then - creative_regions:add_privs_from_string(new_privs_table, areas_guest_privs) + if not areas_individual_override then + creative_regions:add_privs_from_string(new_privs_table, areas_guest_privs) + end end end diff --git a/region.lua b/region.lua index 815b50e..39ff7fb 100644 --- a/region.lua +++ b/region.lua @@ -40,7 +40,7 @@ function creative_regions:decode_privs_table(privs_table) local privs_grant = {} local privs_revoke = {} - table.sort(privs_table) + --table is sorted ascending with priority for _, priv in ipairs(privs_table) do local toggle = string.sub(priv, 1, 1) priv = string.sub(priv, 2)