Flecs v4.0
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
Script

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

Collaboration diagram for Script:

Classes

struct  flecs::script_builder
 Script builder interface. More...

Typedefs

using flecs::Script = EcsScript

Functions

int script_run (const char *name, const char *str) const
 Run script.
int script_run_file (const char *filename) const
 Run script from file.
script_builder script (const char *name=nullptr) const
 Build script.
flecs::string to_expr (flecs::entity_t tid, const void *value)
 Convert value to string.
template<typename T>
flecs::string to_expr (const T *value)
 Convert value to string.
template<typename T>
get_const_var (const char *name, const T &default_value={}) const
 Get value of exported script variable.
template<typename T>
void get_const_var (const char *name, T &out, const T &default_value={}) const
 Get value of exported script variable.
int flecs::world::script_run (const char *name, const char *str) const
 Run script.
int flecs::world::script_run_file (const char *filename) const
 Run script from file.
script_builder flecs::world::script (const char *name=nullptr) const
 Build script.
flecs::string flecs::world::to_expr (flecs::entity_t tid, const void *value)
 Convert value to string.
template<typename T>
flecs::string flecs::world::to_expr (const T *value)
 Convert value to string.
template<typename T>
flecs::world::get_const_var (const char *name, const T &default_value={}) const
 Get value of exported script variable.
template<typename T>
void flecs::world::get_const_var (const char *name, T &out, const T &default_value={}) const
 Get value of exported script variable.

Detailed Description

Data definition format for loading entity data.

Typedef Documentation

◆ Script

Definition at line 21 of file decl.hpp.

Function Documentation

◆ get_const_var() [1/4]

template<typename T>
T flecs::world::get_const_var ( const char * name,
const T & default_value = {} ) const
inline

Get value of exported script variable.

This operation will panic if no const var with the provided name was found, or if the type of the variable cannot be converted to the provided type.

An exported variable can be created in a script like this:

export const x = f64: 10

See the Flecs script manual for more details.

Template Parameters
TThe type of the value to obtain.
Parameters
nameThe name of the exported variable.
default_valueOptional default value. Returned when const var lookup failed.
Returns
The value of the variable.

Definition at line 152 of file impl.hpp.

◆ get_const_var() [2/4]

template<typename T>
void flecs::world::get_const_var ( const char * name,
T & out,
const T & default_value = {} ) const

Get value of exported script variable.

This operation will panic if no const var with the provided name was found, or if the type of the variable cannot be converted to the provided type.

An exported variable can be created in a script like this:

export const x = f64: 10

See the Flecs script manual for more details.

Template Parameters
TThe type of the value to obtain.
Parameters
nameThe name of the exported variable.
outOptional pointer to out variable. Can be used to automatically deduce T.
default_valueOptional default value. Returned when const var lookup failed.

Definition at line 171 of file impl.hpp.

◆ get_const_var() [3/4]

template<typename T>
T get_const_var ( const char * name,
const T & default_value = {} ) const

Get value of exported script variable.

This operation will panic if no const var with the provided name was found, or if the type of the variable cannot be converted to the provided type.

An exported variable can be created in a script like this:

export const x = f64: 10

See the Flecs script manual for more details.

Template Parameters
TThe type of the value to obtain.
Parameters
nameThe name of the exported variable.
default_valueOptional default value. Returned when const var lookup failed.
Returns
The value of the variable.

◆ get_const_var() [4/4]

template<typename T>
void get_const_var ( const char * name,
T & out,
const T & default_value = {} ) const

Get value of exported script variable.

This operation will panic if no const var with the provided name was found, or if the type of the variable cannot be converted to the provided type.

An exported variable can be created in a script like this:

export const x = f64: 10

See the Flecs script manual for more details.

Template Parameters
TThe type of the value to obtain.
Parameters
nameThe name of the exported variable.
outOptional pointer to out variable. Can be used to automatically deduce T.
default_valueOptional default value. Returned when const var lookup failed.

◆ script() [1/2]

script_builder flecs::world::script ( const char * name = nullptr) const
inline

Build script.

See also
ecs_script_init

Definition at line 32 of file world.hpp.

◆ script() [2/2]

script_builder script ( const char * name = nullptr) const

Build script.

See also
ecs_script_init

Definition at line 31 of file mixin.inl.

◆ script_run() [1/2]

int flecs::world::script_run ( const char * name,
const char * str ) const
inline

Run script.

See also
ecs_script_run

Definition at line 18 of file world.hpp.

◆ script_run() [2/2]

int script_run ( const char * name,
const char * str ) const

Run script.

See also
ecs_script_run

Definition at line 17 of file mixin.inl.

◆ script_run_file() [1/2]

int flecs::world::script_run_file ( const char * filename) const
inline

Run script from file.

See also
ecs_script_run_file

Definition at line 25 of file world.hpp.

◆ script_run_file() [2/2]

int script_run_file ( const char * filename) const

Run script from file.

See also
ecs_script_run_file

Definition at line 24 of file mixin.inl.

◆ to_expr() [1/4]

template<typename T>
flecs::string flecs::world::to_expr ( const T * value)
inline

Convert value to string.

Definition at line 44 of file world.hpp.

◆ to_expr() [2/4]

flecs::string flecs::world::to_expr ( flecs::entity_t tid,
const void * value )
inline

Convert value to string.

Definition at line 37 of file world.hpp.

◆ to_expr() [3/4]

template<typename T>
flecs::string to_expr ( const T * value)

Convert value to string.

Definition at line 43 of file mixin.inl.

◆ to_expr() [4/4]

flecs::string to_expr ( flecs::entity_t tid,
const void * value )

Convert value to string.

Definition at line 36 of file mixin.inl.