Minetest mod: Toggle privs in areas
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.6 KiB

--[[
function creative_regions:is_areas_mod(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
local pos2 = areas_area.pos2
local x = math.abs( pos2.x - pos1.x )
local z = math.abs( pos2.z - pos1.x )
return x*z
end
if minetest.get_modpath("areas") then
-- remove protector blocks on area removal
areas:registerOnRemove(function(id)
local area = areas.areas[id]
local area_id = "a"..tostring(id)
creative_regions.set_region_privs(area_id, nil)
creative_regions.save_regions()
local protectors_in_area = minetest.find_nodes_in_area(area.pos1, area.pos2, {"creative_regions:protector_nofly", "creative_regions:protector_arena"})
for _, pos in ipairs(protectors_in_area) do
local meta = minetest.get_meta(pos)
local stored_id = meta:get_string("area_id")
local privstring = meta:get_string("privstring")
local owner = meta:get_string("owner")
if stored_id == area_id then
minetest.remove_node(pos)
minetest.chat_send_player(owner, "[creative_regions] Protector Blocks removed for removed area " .. area_id)
end
end
end)
-- areas mod hud
local function areas_hud_handler(pos, areas)
local current_regions = creative_regions.astore:get_areas_for_pos(pos, false, true)
for astore_id, astore_area in pairs( current_regions ) do
if astore_id then
table.insert(areas, {
id = "region:"..astore_id,
name = astore_area.data,
--owner = "",
})
end
end
end
areas:registerHudHandler(areas_hud_handler)
end