summaryrefslogtreecommitdiff
path: root/honey/ecs/ecs.lua
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-05-09 16:21:47 -0500
committersanine-a <sanine.not@pm.me>2023-05-09 16:21:47 -0500
commitb24a64fd45d71cfc18fea0e333906baceda031c8 (patch)
treed12a3353da5be1fd2faa7529e59fd5b31a0600b0 /honey/ecs/ecs.lua
parent68ef488e8f3bafa0ed68eb8326ac26fd63416891 (diff)
fix bug when getting components no entity has
Diffstat (limited to 'honey/ecs/ecs.lua')
-rw-r--r--honey/ecs/ecs.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/honey/ecs/ecs.lua b/honey/ecs/ecs.lua
index 301ed36..dda99cb 100644
--- a/honey/ecs/ecs.lua
+++ b/honey/ecs/ecs.lua
@@ -179,7 +179,9 @@ end
-- get a specific component from an entity
function EntityDb.getComponent(self, id, name)
self:checkIsValid(id)
- return self.components[name].data[id]
+ local components = self.components[name]
+ if not components then return nil end
+ return components.data[id]
end