Skip to content
ConcordConcordConcord

System

Iterates over Entities, reads their Components, and updates game state.

If the concord folder is in the root directory of your game, you can import this module like so:

System = require('concord.system')

A SystemClass is a template registered on a World via World:addSystem. Each instance belongs to one World and holds zero or more Pools (one per filter key in the definition). Pools: Keys in the definition table become fields on the system instance, each holding a Pool (default List). Iterate with ipairs(system.poolName); when the pool is a List, use pool.size. Event listeners: Every function on the SystemClass except init, onEnabled, and onDisabled is registered when the system is added. World:emit("callbackName", ...) invokes those functions on enabled system instances. Use System.new("Name", ...) and World:emit("Name.callback", ...) to target one system. Flush and pools: On World:flush, added, removed, and dirty Entities are processed; each system’s filters re-evaluate matching Entities and update pool membership.

Name Type Description
ENABLE_OPTIMIZATION boolean When true, shallow-copies class methods onto each instance for faster access (default true)
Method Description
System.new Creates a new SystemClass. The return value is a class; the World constructs instances when the class is added.
System:setEnabled Sets whether the System is enabled.
System:isEnabled Returns whether the System is enabled (enabled systems receive emit callbacks).
System:getWorld Returns the World the System is in.
System:init Callback for system initialization.
System:onEnabled Callback when the system becomes enabled via setEnabled(true).
System:onDisabled Callback when the system becomes disabled via setEnabled(false).
Type Description
SystemClass Registered system type returned by System.new / System().