From d35d62ed3c3717268a35138e5ce18a5247febbe7 Mon Sep 17 00:00:00 2001 From: bakpakin Date: Tue, 16 Jun 2015 19:45:09 -0400 Subject: [PATCH] Add optional filter to tiny.update(world, dt, [filter]) --- tiny.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tiny.lua b/tiny.lua index 0f3e4a0..bcc7978 100644 --- a/tiny.lua +++ b/tiny.lua @@ -621,7 +621,10 @@ end -- Put this in your main loop. -- @param world -- @param dt Delta time -function tiny.update(world, dt) +-- @param filter (Optional) A Filter that selects Systems as if they were +-- Entities, and only updates selected Systems. By default, all Systems are +-- updated. +function tiny.update(world, dt, filter) tiny_manageSystems(world) tiny_manageEntities(world) @@ -632,7 +635,7 @@ function tiny.update(world, dt) -- Iterate through Systems IN ORDER for i = 1, #systems do system = systems[i] - if system.active then + if system.active and ((not filter) or filter(world, system)) then -- Call the modify callback on Systems that have been modified. onModify = system.onModify