mirror of
https://github.com/minetest-mods/areas.git
synced 2025-07-06 18:10:24 +02:00
Add areas:add_with_group function
This commit is contained in:
21
internal.lua
21
internal.lua
@ -96,6 +96,27 @@ function areas:add(owner, name, pos1, pos2, parent)
|
|||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add a area.
|
||||||
|
-- @return The new area's ID.
|
||||||
|
function areas:add_with_group(group, name, pos1, pos2, parent)
|
||||||
|
local id = findFirstUnusedIndex(self.areas)
|
||||||
|
self.areas[id] = {
|
||||||
|
name = name,
|
||||||
|
pos1 = pos1,
|
||||||
|
pos2 = pos2,
|
||||||
|
group = group,
|
||||||
|
parent = parent
|
||||||
|
}
|
||||||
|
-- Add to AreaStore
|
||||||
|
if self.store then
|
||||||
|
local sid = self.store:insert_area(pos1, pos2, tostring(id))
|
||||||
|
if self:checkAreaStoreId(sid) then
|
||||||
|
self.store_ids[id] = sid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return id
|
||||||
|
end
|
||||||
|
|
||||||
--- Remove a area, and optionally it's children recursively.
|
--- Remove a area, and optionally it's children recursively.
|
||||||
-- If a area is deleted non-recursively the children will
|
-- If a area is deleted non-recursively the children will
|
||||||
-- have the removed area's parent as their new parent.
|
-- have the removed area's parent as their new parent.
|
||||||
|
Reference in New Issue
Block a user