Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
Flecs script

Data definition format for loading entity data. More...

Collaboration diagram for Flecs script:

Classes

struct  EcsScript
 
struct  ecs_script_desc_t
 Used with ecs_script_init() More...
 

Macros

#define FLECS_PLECS_H
 
#define ecs_script(world, ...)    ecs_script_init(world, &(ecs_script_desc_t) __VA_ARGS__)
 

Typedefs

typedef struct EcsScript EcsScript
 
typedef struct ecs_script_desc_t ecs_script_desc_t
 Used with ecs_script_init()
 

Functions

FLECS_API ECS_COMPONENT_DECLARE (EcsScript)
 
FLECS_API int ecs_plecs_from_str (ecs_world_t *world, const char *name, const char *str)
 Parse plecs string.
 
FLECS_API int ecs_plecs_from_file (ecs_world_t *world, const char *filename)
 Parse plecs file.
 
FLECS_API ecs_entity_t ecs_script_init (ecs_world_t *world, const ecs_script_desc_t *desc)
 Load managed script.
 
FLECS_API int ecs_script_update (ecs_world_t *world, ecs_entity_t script, ecs_entity_t instance, const char *str, ecs_vars_t *vars)
 Update script with new code.
 
FLECS_API void ecs_script_clear (ecs_world_t *world, ecs_entity_t script, ecs_entity_t instance)
 Clear all entities associated with script.
 
FLECS_API void FlecsScriptImport (ecs_world_t *world)
 

Detailed Description

Data definition format for loading entity data.

Macro Definition Documentation

◆ ecs_script

#define ecs_script ( world,
... )    ecs_script_init(world, &(ecs_script_desc_t) __VA_ARGS__)

Definition at line 98 of file plecs.h.

◆ FLECS_PLECS_H

#define FLECS_PLECS_H

Definition at line 31 of file plecs.h.

Function Documentation

◆ ecs_plecs_from_file()

FLECS_API int ecs_plecs_from_file ( ecs_world_t * world,
const char * filename )

Parse plecs file.

This parses a plecs file and instantiates the entities in the world. This operation is equivalent to loading the file contents and passing it to ecs_plecs_from_str().

Parameters
worldThe world.
filenameThe plecs file name.
Returns
Zero if success, non-zero otherwise.

◆ ecs_plecs_from_str()

FLECS_API int ecs_plecs_from_str ( ecs_world_t * world,
const char * name,
const char * str )

Parse plecs string.

This parses a plecs string and instantiates the entities in the world.

Parameters
worldThe world.
nameThe script name (typically the file).
strThe plecs string.
Returns
Zero if success, non-zero otherwise.

◆ ecs_script_clear()

FLECS_API void ecs_script_clear ( ecs_world_t * world,
ecs_entity_t script,
ecs_entity_t instance )

Clear all entities associated with script.

Parameters
worldThe world.
scriptThe script entity.
instanceThe script instance.

◆ ecs_script_init()

FLECS_API ecs_entity_t ecs_script_init ( ecs_world_t * world,
const ecs_script_desc_t * desc )

Load managed script.

A managed script tracks which entities it creates, and keeps those entities synchronized when the contents of the script are updated. When the script is updated, entities that are no longer in the new version will be deleted.

This feature is experimental.

Parameters
worldThe world.
descScript descriptor.

◆ ecs_script_update()

FLECS_API int ecs_script_update ( ecs_world_t * world,
ecs_entity_t script,
ecs_entity_t instance,
const char * str,
ecs_vars_t * vars )

Update script with new code.

Parameters
worldThe world.
scriptThe script entity.
instanceAn assembly instance (optional).
strThe script code.
varsOptional preset variables for script parameterization.