Add areas:add_with_group function

This commit is contained in:
Cedric Haase 2017-12-17 13:41:35 +01:00
parent 1d80982a1e
commit 81573975b5
1 changed files with 21 additions and 0 deletions

View File

@ -96,6 +96,27 @@ function areas:add(owner, name, pos1, pos2, parent)
return id
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.
-- If a area is deleted non-recursively the children will
-- have the removed area's parent as their new parent.