From a9891abf6d2ea6d2efcd62d83c7b245357bfb174 Mon Sep 17 00:00:00 2001 From: Ukendio Date: Sat, 5 Jul 2025 21:26:05 +0200 Subject: [PATCH] Make callback optional --- addons/observers.luau | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/observers.luau b/addons/observers.luau index 9d84445..0d725f9 100755 --- a/addons/observers.luau +++ b/addons/observers.luau @@ -7,7 +7,7 @@ export type PatchedWorld = jecs.World & { observer: ( PatchedWorld, jecs.Query, - (jecs.Entity) -> () + ((jecs.Entity, jecs.Id, a) -> ())? ) -> () -> (jecs.Entity), monitor: ( PatchedWorld, @@ -40,7 +40,9 @@ local function observers_new(world, query, callback) if jecs.query_match(query, archetype) then i += 1 entities[i] = entity - callback(entity, id, value) + if callback ~= nil then + callback(entity, id, value) + end end end