diff options
Diffstat (limited to 'honey/ecs.lua')
-rw-r--r-- | honey/ecs.lua | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/honey/ecs.lua b/honey/ecs.lua index 69feb12..39f1c77 100644 --- a/honey/ecs.lua +++ b/honey/ecs.lua @@ -69,9 +69,22 @@ function EntityDb.addComponent(self, id, name, value) end +-- add multiple components at once, for convenience +function EntityDb.addComponents(self, id, components) + for name, value in pairs(components) do + self:addComponent(id, name, value) + end +end + + -- get all entities with a given component function EntityDb.queryComponent(self, name) - return self.components[name].data + local component = self.components[name] + if component then + return component.data + else + return {} + end end |