From e96d494526464511cb49af2dac84e6353286f41c Mon Sep 17 00:00:00 2001 From: bakpakin Date: Mon, 4 May 2015 12:05:53 +0800 Subject: [PATCH] Change sorted System calbacks. --- README.md | 4 +++- tiny.lua | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0c0a62a..e775464 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,9 @@ end ``` ## Use It ## -Copy paste tiny.lua into your source folder. +Copy paste tiny.lua into your source folder. For stability and consistent API, +please use a tagged release or use luarocks. Tagged releases will have a version +number in `tiny._VERSION`, while other commits will just have the string 'dev'. ## Luarocks ## Tiny-ecs is also on [Luarocks](https://luarocks.org/) and can be installed with diff --git a/tiny.lua b/tiny.lua index d635950..208391e 100644 --- a/tiny.lua +++ b/tiny.lua @@ -174,9 +174,9 @@ local function sortedSystemOnModify(system, dt) local entityIndices = system.entityIndices local sortDelegate = system.sortDelegate if not sortDelegate then - local sort = system.sort + local compare = system.compare sortDelegate = function(e1, e2) - sort(system, e1, e2) + compare(system, e1, e2) end system.sortDelegate = sortDelegate end @@ -197,7 +197,7 @@ end -- `function system:postProcess(entities, dt)` - returns nil, -- `function system:onAdd(entity)` - returns nil, -- `function system:onRemove(entity)` - returns nil, --- `function system:sort(entity1, entity2)` - returns boolean. +-- `function system:compare(entity1, entity2)` - returns boolean. -- For Filters, it is conveient to use `tiny.requireAll` or `tiny.requireOne`, -- but one can write their own filters as well. -- @param table A table to be used as a System, or `nil` to create a new @@ -207,6 +207,7 @@ function tiny.sortedSystem(table) table[systemTableKey] = true table.update = processingSystemUpdate table.onModify = sortedSystemOnModify + table.sort = sortedSystemOnModify return table end