Module lovelyecs.lua
Entity component system for Lua scripting language.
Info:
- Copyright: 2019
- License: MIT
- Author: Markus Septer
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. |
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 |
-
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:
Returns:
entity_id
-
lovelyecs.removeAllEntities (world_id)
-
Removes all entities from given world.
Parameters:
-
lovelyecs.getEntityCount (world_id)
-
Returns number of entities in given world.
Parameters:
-
lovelyecs.getWorldCount ()
-
Retuns the number of world's that exist.
-
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:
-
lovelyecs.removeAllComponents (world_id, entity_id)
-
Removes all components from entity.
Parameters:
-
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
-
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
-
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
-
lovelyecs.eraseStorage ()
-
NOTE: use with caution, used mostly for testing purposes.