13 Commits

Author SHA1 Message Date
Calvin Rose
821914795d Merge pull request #25 from yangruihan/master
fix README.md example error
2020-11-03 07:18:04 -06:00
C.y
2beca9a0ad fix README.md example error 2020-11-03 19:35:44 +08:00
Calvin Rose
afd7d326d7 Fix #22 - manage systems before setSystemIndex 2020-08-12 08:28:57 -05:00
Calvin Rose
e095e10d44 Merge pull request #21 from RantingBob/patch-1
Fixed nil entitylist in nocache system
2020-02-23 21:21:05 -06:00
Bob Gardner
3c4b3a7f68 Fixed nil entitylist in nocache system
Systems that set nocache to true would fail as the entity list was set to system.world.entityList but should have been system.world.entities.
2020-02-23 16:45:01 -08:00
Calvin Rose
0f17f116ab Update .travis.yml 2019-10-13 00:14:12 -05:00
Calvin Rose
584be2c952 Merge pull request #20 from firoxer/patch-1 2019-10-13 01:09:55 -04:00
Oliver Vartiainen
36364df4e6 Fix a few spellings in the README
Hi! While reading the README I noticed a few things that could be corrected. Here they are. Thanks for the project, it's very interesting!
2019-10-12 22:02:37 +03:00
Calvin Rose
65de2a9c6f Merge pull request #19 from wqferr/fix-init-lua
Fix init.lua
2019-07-23 08:40:27 -05:00
William Ferreira
4631216c27 Fix init.lua 2019-07-23 00:40:11 -03:00
Calvin Rose
7c7de1db0c Update README.md 2019-01-23 16:57:20 -05:00
bakpakin
fe7e2854de Update doc. 2016-08-10 21:48:20 -04:00
bakpakin
311943e070 Fix doc bug. 2016-08-10 21:42:18 -04:00
6 changed files with 46 additions and 17 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
language: erlang
language: c
env:
global:
- LUAROCKS_BASE=luarocks-2.2.2
- LUAROCKS_BASE=luarocks-3.2.1
matrix:
- LUA=lua5.1 LUA_DEV=liblua5.1-dev LUA_VER=5.1 LUA_SFX=5.1 LUA_INCDIR=/usr/include/lua5.1
- LUA=lua5.2 LUA_DEV=liblua5.2-dev LUA_VER=5.2 LUA_SFX=5.2 LUA_INCDIR=/usr/include/lua5.2
+14 -7
View File
@@ -1,5 +1,12 @@
# tiny-ecs #
## NOTE
Although there have been almost no commits in several years, this
project is not abandoned. tiny-ecs is, for most intents and
purposes, finished, and no bugs have been brought to my attention in a while.
New issues on GitHub will be addressed.
[![Build Status](https://travis-ci.org/bakpakin/tiny-ecs.png?branch=master)](https://travis-ci.org/bakpakin/tiny-ecs)[![License](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE)
Tiny-ecs is an Entity Component System for Lua that's simple, flexible, and useful.
@@ -8,11 +15,11 @@ for simulating large and complex systems. For more explanation on Entity
Component Systems, here is some
[basic info](http://en.wikipedia.org/wiki/Entity_component_system "Wikipedia").
Tiny-ecs also works well with objected oriented programming in Lua because
Tiny-ecs also works well with object-oriented programming in Lua because
Systems and Entities do not use metatables. This means you can subclass your
Systems and Entities, and use existing Lua class frameworks with tiny-ecs, no problem.
Systems and Entities and use existing Lua class frameworks with tiny-ecs, no problem.
For an example on how to use tiny-ecs with object-oriented Lua, take a look at the
demo branch, specifically the systems and entities sub-directories.
demo branch, specifically the systems and entities subdirectories.
## Overview ##
Tiny-ecs has four important types: Worlds, Filters, Systems, and Entities.
@@ -21,7 +28,7 @@ take an Entity as a parameter.
### Entities ###
Entities are simply Lua tables of data that gets processed by Systems. Entities
should contain primarily data rather than code, as it is the Systems's job to
should contain primarily data rather than code, as it is the System's job to
do logic on data. Henceforth, a key-value pair in an Entity will
be referred to as a Component.
@@ -49,7 +56,7 @@ local talkingSystem = tiny.processingSystem()
talkingSystem.filter = tiny.requireAll("name", "mass", "phrase")
function talkingSystem:process(e, dt)
e.mass = e.mass + dt * 3
print(("%s who weighs %d pounds, says %q."):format(e.name, e.mass, e.phrase)
print(("%s who weighs %d pounds, says %q."):format(e.name, e.mass, e.phrase))
end
local joe = {
@@ -68,10 +75,10 @@ end
## Use It ##
Copy paste tiny.lua into your source folder. For stability and consistent API,
please use a tagged release or use luarocks.
please use a tagged release or use LuaRocks.
## Luarocks ##
Tiny-ecs is also on [Luarocks](https://luarocks.org/) and can be installed with
Tiny-ecs is also on [LuaRocks](https://luarocks.org/) and can be installed with
`luarocks install tiny-ecs`.
## Demo ##
+3 -2
View File
@@ -1,5 +1,6 @@
-- Helper Lua file for easy require if tiny-ecs is used as a git submodule or
-- folder. Not needed in many cases, including luarocks distribution.
local directory = (...):match("(.-)[^%.]+$")
return require(directory .. 'tiny')
local args = {...}
local directory = args[1]
return require(directory .. '.tiny')
+10
View File
@@ -310,4 +310,14 @@ describe('tiny-ecs:', function()
assert.are.same(_G, GLOBALS)
end)
it("Can set system indices", function()
local world = tiny.world()
local systemA = tiny.system()
local systemB = tiny.system()
world:addSystem(systemA)
world:addSystem(systemB)
world:setSystemIndex(systemA, 1)
assert(true)
end)
end)
+8
View File
@@ -0,0 +1,8 @@
local tiny = require('tiny')
local world = tiny.world()
local systemA = tiny.system()
local systemB = tiny.system()
world:addSystem(systemA)
world:addSystem(systemB)
world:setSystemIndex(systemA, 1)
+9 -6
View File
@@ -230,7 +230,7 @@ end
-- removed from the world, after all Entities are removed from the System.
-- * `function system:preWrap(dt)` - Called on each system before update is
-- called on any system.
-- * `function system:postWrap(dt) - Called on each system in reverse order
-- * `function system:postWrap(dt)` - Called on each system in reverse order
-- after update is called on each system. The idea behind `preWrap` and
-- `postWrap` is to allow for systems that modify the behavior of other systems.
-- Say there is a DrawingSystem, which draws sprites to the screen, and a
@@ -278,11 +278,13 @@ end
--
-- There is another option to (hopefully) increase performance in systems that
-- have items added to or removed from them often, and have lots of entities in
-- them. Setting the `nocache' field of the system might improve performance.
-- them. Setting the `nocache` field of the system might improve performance.
-- It is still experimental. There are some restriction to systems without
-- caching, however. * There is no `entities` table. * Callbacks such onAdd,
-- onRemove, and onModify will never be called * Noncached systems cannot be
-- sorted (There is no entities list to sort).
-- caching, however.
--
-- * There is no `entities` table.
-- * Callbacks such onAdd, onRemove, and onModify will never be called
-- * Noncached systems cannot be sorted (There is no entities list to sort).
--
-- @section System
@@ -307,7 +309,7 @@ local function processingSystemUpdate(system, dt)
if process then
if system.nocache then
local entities = system.world.entityList
local entities = system.world.entities
local filter = system.filter
if filter then
for i = 1, #entities do
@@ -819,6 +821,7 @@ end
-- the order in which they Systems processed, because lower indexed Systems are
-- processed first. Returns the old system.index.
function tiny.setSystemIndex(world, system, index)
tiny_manageSystems(world)
local oldIndex = system.index
local systems = world.systems