Entity's Keys

You can now give the 'key' component to Entities.

A key will be generated automatically and stored in Entity.key.value.

You can then use this key to fetch the Entity from the World with World:getEntityByKey(key)

The keys are generated with a generator function that can be overriden.
This commit is contained in:
Pablo Ariel Mayobre 2023-02-14 18:14:25 -03:00
parent 3d195c790f
commit a55efd042a
6 changed files with 148 additions and 15 deletions

View file

@ -48,6 +48,8 @@ System.mt = {
-- @param table filters A table containing filters (name = {components...})
-- @treturn System A new SystemClass
function System.new(definition)
definition = definition or {}
for name, def in pairs(definition) do
if type(name) ~= 'string' then
Utils.error(2, "invalid name for filter (string key expected, got %s)", type(name))