According to what I understood, CubeScript hardcoded variable and commands , ok, implemented via macros but not a so simplistic way.
The way it's implemented allow to add commands this way in most of the C++ source code :
type acommand (arguments) {
code
of
the
command
}
COMMAND(acommand, args);
//This is enough to use this as native CubeScript funtions
Hardcoded variables are implemented a similar way.
Here are the macros :
// nasty macros for registering script functions, abuses globals to avoid excessive infrastructure
#define COMMANDN(name, fun, sig) static bool __dummy_##fun = addcommand(#name, (void (*)())fun, sig)
#define COMMAND(name, sig) COMMANDN(name, name, sig)
#define COMMANDF(name, sig, inlinefunc) static void __dummy_##name inlinefunc ; COMMANDN(name, __dummy_##name, sig)
#define VARP(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, true)
#define VAR(name, min, cur, max) int name = variable(#name, min, cur, max, &name, NULL, false)
#define VARN(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, NULL, false)
#define VARNP(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, NULL, true)
#define VARF(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, false)
#define VARFP(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, true)
#define FVARP(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, true)
#define FVAR(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, false)
#define FVARF(name, min, cur, max, body) extern float name; void var_##name() { body; } float name = fvariable(#name, min, cur, max, &name, var_##name, false)
#define FVARFP(name, min, cur, max, body) extern float name; void var_##name() { body; } float name = fvariable(#name, min, cur, max, &name, var_##name, true)
#define SVARP(name, cur) char *name = svariable(#name, cur, &name, NULL, true)
#define SVAR(name, cur) char *name = svariable(#name, cur, &name, NULL, false)
#define SVARF(name, cur, body) extern char *name; void var_##name() { body; } char *name = svariable(#name, cur, &name, var_##name, false)
#define SVARFP(name, cur, body) extern char *name; void var_##name() { body; } char *name = svariable(#name, cur, &name, var_##name, true)
This is from the file command.h of the AssaultCube Reloaded source code (probably identical to the AssaultCube one).
In the Cube source code, there is a variant, with only six of these seveteen macros, in cube.h.
In each cases, the functions called are in command are in command.cpp.
It maybe is as hacky as the Quake 3 fast inverse square root(https://en.wikipedia.org/wiki/Fast_inverse_square_root) but it allow easy adds of hardcoded variables and commands.
You claim the CubeScript isn't a true script language and can't be improved. I disagree with both.
The CubeScript is a true script language. It's its purpose.
And about improving the CubeScript, anyone can do it if he/she can compile a game using it.
About DECORATE like features with CubeScript There is something similar to what I suggest in Platinum Arts Sandbox (using the Cube 2 Engine) but in this game, there is a file for each object (you can't define several objects in an same file) and a folder and a folder for each type of objects (the type of an object depend on the name of the folder where it's defined).
The way I thought to implement this doesn't need several files.
reply to this message
|