Libprimis
Imprimis' 3D destroyable world engine
|
Script binding functionality. More...
Go to the source code of this file.
Classes | |
struct | identval |
struct | tagval |
struct | identstack |
struct | ident |
An object representing all Cubescript objects. More... | |
union | ident::identvalptr |
Macros | |
#define | VAR_(name, global, min, cur, max, persist) |
#define | VARN(name, global, min, cur, max) |
#define | VARNP(name, global, min, cur, max) |
#define | VARNR(name, global, min, cur, max) |
#define | VAR(name, min, cur, max) |
#define | VARP(name, min, cur, max) |
#define | VARR(name, min, cur, max) |
#define | VARF_(name, global, min, cur, max, body, persist) |
#define | VARFN(name, global, min, cur, max, body) |
#define | VARF(name, min, cur, max, body) |
#define | VARFP(name, min, cur, max, body) |
#define | VARFR(name, min, cur, max, body) |
#define | VARFNP(name, global, min, cur, max, body) |
#define | HVAR_(name, global, min, cur, max, persist) |
#define | HVARP(name, min, cur, max) |
#define | HVARF_(name, global, min, cur, max, body, persist) |
#define | CVAR_(name, cur, init, body, persist) |
#define | CVARP(name, cur) |
#define | CVARR(name, cur) |
#define | CVARFP(name, cur, body) |
#define | CVAR0_(name, cur, body, persist) |
#define | CVAR0R(name, cur) |
#define | CVAR1_(name, cur, body, persist) |
#define | CVAR1R(name, cur) |
#define | CVAR1FR(name, cur, body) |
#define | FVAR_(name, global, min, cur, max, persist) |
#define | FVARNP(name, global, min, cur, max) |
#define | FVAR(name, min, cur, max) |
#define | FVARP(name, min, cur, max) |
#define | FVARR(name, min, cur, max) |
#define | FVARF_(name, global, min, cur, max, body, persist) |
#define | FVARF(name, min, cur, max, body) |
#define | FVARFP(name, min, cur, max, body) |
#define | FVARFR(name, min, cur, max, body) |
#define | SVAR_(name, global, cur, persist) |
#define | SVAR(name, cur) |
#define | SVARP(name, cur) |
#define | SVARR(name, cur) |
#define | SVARF_(name, global, cur, body, persist) |
#define | SVARF(name, cur, body) |
#define | SVARFR(name, cur, body) |
Typedefs | |
typedef void(__cdecl * | identfun) (ident *id) |
Functions | |
void | intret (int v) |
Returns an integer value from a Cubescript command. | |
const char * | floatstr (float v) |
void | floatret (float v) |
Returns a float value from a Cubescript command. | |
void | stringret (char *s) |
Returns a string value from a Cubescript command. | |
void | result (const char *s) |
Returns an alias' name from a Cubescript command. | |
int | parseint (const char *s) |
Returns the string passed as an integer. | |
int | variable (const char *name, int min, int cur, int max, int *storage, identfun fun, int flags) |
Registers an int variable in the Cubescript ident table. | |
float | fvariable (const char *name, float min, float cur, float max, float *storage, identfun fun, int flags) |
Registers a float variable in the Cubescript ident table. | |
char * | svariable (const char *name, const char *cur, char **storage, identfun fun, int flags) |
Registers a C string variable in the Cubescript ident table. | |
void | setvar (const char *name, int i, bool dofunc=true, bool doclamp=true) |
Sets a Cubescript integer value to the given value. | |
void | setfvar (const char *name, float f, bool dofunc=true, bool doclamp=true) |
Sets a Cubescript float value to the given value. | |
void | setsvar (const char *name, const char *str, bool dofunc=true) |
Sets a Cubescript string value to the given value. | |
bool | addcommand (const char *name, identfun fun, const char *narg="", int type=Id_Command) |
Registers a command in the Cubescript ident table. | |
ident * | getident (const char *name) |
Returns the pointer to the ident object with the given CS alias. | |
int | execute (const uint *code) |
int | execute (const char *p) |
Executes the contents of the string passed. | |
int | execident (const char *name, int noid=0, bool lookup=false) |
Executes the contents of an ident, searched by name. | |
bool | executebool (const uint *code) |
bool | execfile (const char *cfgfile, bool msg=true) |
Executes the contents of the referenced file. | |
const char * | escapestring (const char *s) |
Replaces C style excape characters with Cubescript ones. | |
void | printvar (const ident *id, int i) |
Prints out the formatted variable. | |
int | clampvar (bool hex, std::string name, int i, int minval, int maxval) |
Modifies the value passed to fall within the boundaries passed. | |
void | loopiter (ident *id, identstack &stack, int i) |
void | loopend (ident *id, identstack &stack) |
const char * | escapeid (const char *s) |
Escapes a string unless it is null. | |
void | writecfg (const char *savedconfig, const char *autoexec=nullptr, const char *defaultconfig=nullptr, const char *name=nullptr) |
Writes out the state of the CubeScript idents to a file. | |
void | checksleep (int millis) |
Processes the cubescript sleep queue. | |
bool | initidents () |
Initializes the CubeScript preset argument idents. | |
void | clear_command () |
Clears all aliases from the ident map. | |
Variables | |
std::queue< ident * > | triggerqueue |
int | identflags |
Script binding functionality.
This file describes the CubeScript API for binding and executing code from within the engine's CubeScript context.
#define CVAR0_ | ( | name, | |
cur, | |||
body, | |||
persist ) |
#define CVAR0R | ( | name, | |
cur ) |
#define CVAR1_ | ( | name, | |
cur, | |||
body, | |||
persist ) |
#define CVAR1FR | ( | name, | |
cur, | |||
body ) |
#define CVAR1R | ( | name, | |
cur ) |
#define CVAR_ | ( | name, | |
cur, | |||
init, | |||
body, | |||
persist ) |
#define CVARFP | ( | name, | |
cur, | |||
body ) |
#define CVARP | ( | name, | |
cur ) |
#define CVARR | ( | name, | |
cur ) |
#define FVAR | ( | name, | |
min, | |||
cur, | |||
max ) |
#define FVAR_ | ( | name, | |
global, | |||
min, | |||
cur, | |||
max, | |||
persist ) |
#define FVARF | ( | name, | |
min, | |||
cur, | |||
max, | |||
body ) |
#define FVARF_ | ( | name, | |
global, | |||
min, | |||
cur, | |||
max, | |||
body, | |||
persist ) |
#define FVARFP | ( | name, | |
min, | |||
cur, | |||
max, | |||
body ) |
#define FVARFR | ( | name, | |
min, | |||
cur, | |||
max, | |||
body ) |
#define FVARNP | ( | name, | |
global, | |||
min, | |||
cur, | |||
max ) |
#define FVARP | ( | name, | |
min, | |||
cur, | |||
max ) |
#define FVARR | ( | name, | |
min, | |||
cur, | |||
max ) |
#define HVAR_ | ( | name, | |
global, | |||
min, | |||
cur, | |||
max, | |||
persist ) |
#define HVARF_ | ( | name, | |
global, | |||
min, | |||
cur, | |||
max, | |||
body, | |||
persist ) |
#define HVARP | ( | name, | |
min, | |||
cur, | |||
max ) |
#define SVAR | ( | name, | |
cur ) |
#define SVAR_ | ( | name, | |
global, | |||
cur, | |||
persist ) |
#define SVARF | ( | name, | |
cur, | |||
body ) |
#define SVARF_ | ( | name, | |
global, | |||
cur, | |||
body, | |||
persist ) |
#define SVARFR | ( | name, | |
cur, | |||
body ) |
#define SVARP | ( | name, | |
cur ) |
#define SVARR | ( | name, | |
cur ) |
#define VAR | ( | name, | |
min, | |||
cur, | |||
max ) |
#define VAR_ | ( | name, | |
global, | |||
min, | |||
cur, | |||
max, | |||
persist ) |
#define VARF | ( | name, | |
min, | |||
cur, | |||
max, | |||
body ) |
#define VARF_ | ( | name, | |
global, | |||
min, | |||
cur, | |||
max, | |||
body, | |||
persist ) |
#define VARFN | ( | name, | |
global, | |||
min, | |||
cur, | |||
max, | |||
body ) |
#define VARFNP | ( | name, | |
global, | |||
min, | |||
cur, | |||
max, | |||
body ) |
#define VARFP | ( | name, | |
min, | |||
cur, | |||
max, | |||
body ) |
#define VARFR | ( | name, | |
min, | |||
cur, | |||
max, | |||
body ) |
#define VARN | ( | name, | |
global, | |||
min, | |||
cur, | |||
max ) |
#define VARNP | ( | name, | |
global, | |||
min, | |||
cur, | |||
max ) |
#define VARNR | ( | name, | |
global, | |||
min, | |||
cur, | |||
max ) |
#define VARP | ( | name, | |
min, | |||
cur, | |||
max ) |
#define VARR | ( | name, | |
min, | |||
cur, | |||
max ) |
|
extern |
Registers a command in the Cubescript ident table.
The arguments of the function passed are cast away, so they are reconstructed using the char * string passed to narg
.
name | of the command in Cubescript |
fun | a function pointer to be called when the command is executed |
narg | string containing the arguments of the function |
type | the type of the command to create |
|
extern |
Processes the cubescript sleep queue.
At most, one sleep command is removed from the queue per cycle. Removes queued sleep commands as they expire, which stops CS commands from executing for a certain period of time.
millis | the current timestamp |
|
extern |
Modifies the value passed to fall within the boundaries passed.
Clamps the value i to within minval and maxval. If hex is passed, warns in hex mode, otherwise decimal. If the values are not within bounds, issued aformentioned warning, refering to the passed name in the console message.
hex | toggles whether to display hex warning instead of decimal |
name | the name |
i | the value to clamp |
minval | the lowest value to clamp to |
maxval | the largest value to clamp to |
|
extern |
Clears all aliases from the ident map.
All aliases, aka objects created from within CubeScript, have their contents (the names and code values associated with them) freed. Does not remove the ident object itself from the global ident map.
const char * escapeid | ( | const char * | s | ) |
Escapes a string unless it is null.
If an empty string is passed, escapestring() is not called. Otherwise, the same behavior as in escapestring() is executed.
s | the string to convert |
|
extern |
Replaces C style excape characters with Cubescript ones.
The resulting string is also wrapped in quotes ("").
s | the string to convert |
|
extern |
Executes the contents of the referenced file.
cfgfile | the relative director of the file to execute |
msg | whether to print to console a failure message |
|
extern |
Executes the contents of an ident, searched by name.
Attempts to find in the ident table an ident with the given name, and if found executes it.
name | the name of the ident to look for |
noid | the value to return if no ident is found |
lookup | if a command, and parameters are of format 'N', sets to -1 |
|
extern |
Executes the contents of the string passed.
Parses and executes the line of Cubescript given.
p | the C string containing the code to execute |
|
extern |
Returns a float value from a Cubescript command.
When writing a CS command, this function returns a float value to the inheriting CS environment.
v | the value to return |
|
extern |
Registers a float variable in the Cubescript ident table.
Adds a float variable to the Cubescript ident table. The name of the Cubescript variable does not necessarily need to correspond to the C++ variable's name.
name | the name of the aliased variable in Cubescript |
min | the minimum value the variable can be set at |
cur | the starting value of the variable |
max | the maximum value the variable can be set at |
storage | the pointer to the variable to be aliased to Cubescript |
fun | a function pointer to be called upon modification of the variable |
flags | the handling flags for the variable |
|
extern |
Returns the pointer to the ident object with the given CS alias.
the | name of the cubescript object to get |
|
extern |
Initializes the CubeScript preset argument idents.
Intitializes the argument parameters (arg1, arg2, ..., arg<Max_Args>) as CS ident objects. Required to use of $argN variables. Also initializes the dummy ident, //dummy
.
|
extern |
Returns an integer value from a Cubescript command.
When writing a CS command, this function returns an integer value to the inheriting CS environment.
v | the value to return |
|
inline |
Returns the string passed as an integer.
Parses the entire string, returning the value of the passed value as an integer. The value of this value will always be greater than zero unless there is an overflow beyond the size of int
. The output may be converted by a trailing radix digit as described in strtoul
.
s | the string to turn into an integer |
|
extern |
Prints out the formatted variable.
The param is intended to represent the value the ident object represents.
id | the ident object to print out |
i | the value to print out the variable equalling. |
|
extern |
Returns an alias' name from a Cubescript command.
When writing a CS command, this functions a string value representing the name of a Cubescript object to the inheriting CS environment.
s | the name of the ident to return |
|
extern |
Sets a Cubescript float value to the given value.
name | the name of the cubescript alias to change |
i | the value to set |
dofunc | whether to run the onchange function |
doclamp | whether to clamp the value to the specified limits |
|
extern |
Sets a Cubescript string value to the given value.
name | the name of the cubescript alias to change |
i | the value to set |
dofunc | whether to run the onchange function |
|
extern |
Sets a Cubescript integer value to the given value.
name | the name of the cubescript alias to change |
i | the value to set |
dofunc | whether to run the onchange function |
doclamp | whether to clamp the value to the specified limits |
|
extern |
Returns a string value from a Cubescript command.
When writing a CS command, this function returns a string value to the inheriting CS environment.
v | the value to return |
|
extern |
Registers a C string variable in the Cubescript ident table.
name | the name of the aliased variable in Cubescript |
cur | the starting value of the variable |
storage | the pointer to the pointer to the variable to be aliased to Cubescript |
fun | a function pointer to be called upon modification of the variable |
flags | the handling flags for the variable |
|
extern |
Registers an int variable in the Cubescript ident table.
name | the name of the aliased variable in Cubescript |
min | the minimum value the variable can be set at |
cur | the starting value of the variable |
max | the maximum value the variable can be set at |
storage | the pointer to the variable to be aliased to Cubescript |
fun | a function pointer to be called upon modification of the variable |
flags | the handling flags for the variable |
|
extern |
Writes out the state of the CubeScript idents to a file.
savedconfig | the path to write to if name is nullptr |
autoexec | the path for the autoexec file for user modification, for display in top of file comment |
defaultconfig | the path for the master copy of the configuration file, for display in top of file comment |
name | the path to write to, if nullptr savedconfig is used instead |
|
extern |
The flags to automatically set on ident objects
|
extern |
A queue of game events for the engine to process