Module lovelyecs.lua

Entity component system for Lua scripting language.

Info:

  • Copyright: 2019
  • License: MIT
  • Author: Markus Septer

World functions

lovelyecs.newWorld () Creates new world and returns it's id.
lovelyecs.newEntity (world_id, optional_prefab_name) Creates new entity into specified world and returns it's id.
lovelyecs.removeEntity (world_id, entity_id) Removes entity entity from world and returns it's id.
lovelyecs.removeAllEntities (world_id) Removes all entities from given world.
lovelyecs.getEntityCount (world_id) Returns number of entities in given world.
lovelyecs.getWorldCount () Retuns the number of world's that exist.

Entity functions

lovelyecs.addComponent (world_id, entity_id, name, value) Adds component to entity, if it didn't exist previously.
lovelyecs.changeComponent (world_id, entity_id, name, value) Changes existing component value.
lovelyecs.setComponent (world_id, entity_id, name, value) If component doesn't exist creates it with specified value.
lovelyecs.getComponent (world_id, entity_id, component_name) Returns component value.
lovelyecs.getComponents (world_id, entity_id, component_table) Returns multiple component values.
lovelyecs.removeComponent (world_id, entity_id, name) Removes component from entity.
lovelyecs.removeAllComponents (world_id, entity_id) Removes all components from entity.

Prefab functions

lovelyecs.registerPrefab (prefab_name, table_of_components) Packs components into prefab
lovelyecs.addPrefab (world_id, entity_id, prefab_name, is_forceful) Adds prefab with packed components to entity.

Query functions

lovelyecs.withNeither (world_id, entity_id, filter, return_components) Returns entities with neither components
lovelyecs.withOnly (world_id, entity_id, filter, return_components) Returns entities with only components
lovelyecs.withAll (world_id, entity_id, filter, return_components) Returns entities with all components
lovelyecs.withAny (world_id, entity_id, filter, return_components) Returns entities with any components

Validation functions

lovelyecs.hasNeitherComponents (world_id, entity_id, components_table) Has neither components.
lovelyecs.hasOnlyComponents (world_id, entity_id, components_table) Has only components.
lovelyecs.hasAllComponents (world_id, entity_id, components_table) Has all components.
lovelyecs.hasAnyComponents (world_id, entity_id, components_table) Has any components.

Storage functions

lovelyecs.eraseStorage () NOTE: use with caution, used mostly for testing purposes.


World functions

lovelyecs.newWorld ()
Creates new world and returns it's id.

Returns:

    world_id
lovelyecs.newEntity (world_id, optional_prefab_name)
Creates new entity into specified world and returns it's id.

Parameters:

  • world_id
  • optional_prefab_name

Returns:

    entity_id
lovelyecs.removeEntity (world_id, entity_id)
Removes entity entity from world and returns it's id.

Parameters:

  • world_id
  • entity_id

Returns:

    entity_id
lovelyecs.removeAllEntities (world_id)
Removes all entities from given world.

Parameters:

  • world_id
lovelyecs.getEntityCount (world_id)
Returns number of entities in given world.

Parameters:

  • world_id
lovelyecs.getWorldCount ()
Retuns the number of world's that exist.

Entity functions

lovelyecs.addComponent (world_id, entity_id, name, value)
Adds component to entity, if it didn't exist previously.

Parameters:

  • world_id
  • entity_id
  • name
  • value
lovelyecs.changeComponent (world_id, entity_id, name, value)
Changes existing component value.

Parameters:

  • world_id
  • entity_id
  • name
  • value
lovelyecs.setComponent (world_id, entity_id, name, value)
If component doesn't exist creates it with specified value.

Parameters:

  • world_id
  • entity_id
  • name
  • value
lovelyecs.getComponent (world_id, entity_id, component_name)
Returns component value.

Parameters:

  • world_id
  • entity_id
  • component_name
lovelyecs.getComponents (world_id, entity_id, component_table)
Returns multiple component values.

Parameters:

  • world_id
  • entity_id
  • component_table
lovelyecs.removeComponent (world_id, entity_id, name)
Removes component from entity.

Parameters:

  • world_id
  • entity_id
  • name
lovelyecs.removeAllComponents (world_id, entity_id)
Removes all components from entity.

Parameters:

  • world_id
  • entity_id

Prefab functions

lovelyecs.registerPrefab (prefab_name, table_of_components)
Packs components into prefab

Parameters:

  • prefab_name
  • table_of_components
lovelyecs.addPrefab (world_id, entity_id, prefab_name, is_forceful)
Adds prefab with packed components to entity.

Parameters:

  • world_id
  • entity_id
  • prefab_name
  • is_forceful

Query functions

lovelyecs.withNeither (world_id, entity_id, filter, return_components)
Returns entities with neither components

Parameters:

  • world_id
  • entity_id
  • filter
  • return_components
lovelyecs.withOnly (world_id, entity_id, filter, return_components)
Returns entities with only components

Parameters:

  • world_id
  • entity_id
  • filter
  • return_components
lovelyecs.withAll (world_id, entity_id, filter, return_components)
Returns entities with all components

Parameters:

  • world_id
  • entity_id
  • filter
  • return_components
lovelyecs.withAny (world_id, entity_id, filter, return_components)
Returns entities with any components

Parameters:

  • world_id
  • entity_id
  • filter
  • return_components

Validation functions

lovelyecs.hasNeitherComponents (world_id, entity_id, components_table)
Has neither components.

Parameters:

  • world_id
  • entity_id
  • components_table

Returns:

    true or false
lovelyecs.hasOnlyComponents (world_id, entity_id, components_table)
Has only components.

Parameters:

  • world_id
  • entity_id
  • components_table

Returns:

    true or false
lovelyecs.hasAllComponents (world_id, entity_id, components_table)
Has all components.

Parameters:

  • world_id
  • entity_id
  • components_table

Returns:

    true or false
lovelyecs.hasAnyComponents (world_id, entity_id, components_table)
Has any components.

Parameters:

  • world_id
  • entity_id
  • components_table

Returns:

    true or false

Storage functions

lovelyecs.eraseStorage ()
NOTE: use with caution, used mostly for testing purposes.
generated by LDoc 1.4.6 Last updated 2019-06-13 23:52:40