From b24a64fd45d71cfc18fea0e333906baceda031c8 Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 9 May 2023 16:21:47 -0500 Subject: fix bug when getting components no entity has --- honey/ecs/ecs.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'honey/ecs/ecs.lua') 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 -- cgit v1.2.1