Welcome to the DarkScript WIP thread!
This plugin will extend the features of DBPro by offering a scripting engine that borrows concepts from Lua, but at the same time resembles the C language and DGSDK. Since this engine can be used in the same fashion as either of those just languages I believe DarkScript will become a very popular plugin to use!
Features include:
- Ability to load multiple scripts, and even have multiple threads per script to control various objects, AI, and other functions you have in the script.
- Access within the script to different command sets like, DBPro commands, extra rotation commands, string, math, SQL, net, etc. Some of these command sets will be dynamic as well, meaning you can chose in your script whether or not they should be loaded to save memory.
Here's a very generic example of a function in DarkScript:
global test = function()
{
w = 2.3E-3;
// You can convert integers and floats to string
x = w.String();
// The entire DBPro command set will be at your reach
SetCursor(1,1);
PrintString(x);
WaitKey();
};
More complex looking function:
global particle = function(x, y) {
global detec;
global clearExplo;
pcoltab = table(CA.F_RED|CA.F_INTENSITY, CA.F_RED|CA.F_GREEN|CA.F_INTENSITY, CA.F_RED|CA.F_GREEN|CA.F_BLUE|CA.F_INTENSITY);
pfrtab = table(".", "+", "*");
xmom = randfloat(-1.0,1.0);
// ymom = randfloat(-0.2,-2.0);
ymom = randfloat(-2.0,-0.2);
xpos = x.Float();
ypos = y.Float();
frame = -1;
time = randint(10,40);
from = time;
frint = randint(0,3);
while (1) {
if (y < detec[x]) {
CATTRIB(CA.F_BLUE | CA.B_BLUE);
XYTEXT(x,y," ");
}
xpos = xpos + xmom;
ypos = ypos + ymom;
ymom = ymom + 0.15f;
x = xpos.Int();
y = ypos.Int();
// On Screen
if ( y >= height || y < 0 || x < 0 || x > 79) {
exit();
}
// Out of Time ?
time = time - 1;
if (time < 0 || clearExplo) {
exit();
}
if (y < detec[x]) {
fr = (time*3) / from;
CATTRIB(pcoltab[fr] | CA.B_BLUE);
XYTEXT(x,y,pfrtab[frint]);
}
// Sync to the master frame
while (frame == gframe) {
yield();
}
frame = gframe;
}
};
After you load your script into your game/program you would issue a command like the one below to execute the function.
script function "test"
With DarkScript your variables have a wide array of options, below are some examples:
a = null; //no value
a = "test"; //strings
a = 23; //integers
a = 23.9; //floats
a = table(); //basically an array
a = function() {}; //functions can have parameters also (and can return values)
a = 2.3E-3; //scientific notation
a = 0xA7; //hexidecimal
a = 0b10100111; //binary
Here's some common keywords you might recognize:
if, for, foreach, while, dowhile, break, continue, return, true, false, null
The entire script command list to this engine is very large, and because of how I designed the framework of this plugin adding new commands is nearly effortless, so suggestions for command set ideas are more then welcome.
Below is the list of commands (dbp):
LOAD SCRIPT script file
Syntax: load script "somefile.gm"
Note: It is possible to load more then 1 script. If a second script loads with a variable or function with the same name, the newest one that is loaded overwrites the old one.
SCRIPT FUNCTION script function name (no returns)
Syntax: script function "somefunc"
Note: Use this command for functions that return no value.
SCRIPT FUNCTION INT script function name (returns a integer)
Syntax: someint = script function int("someintfunc")
Note: Use with functions that return an integer back to DarkBASIC Pro.
SCRIPT FUNCTION FLOAT script function name (returns a float)
Syntax: floatval# = script function float("floatfunc")
Note: Use with functions that return a float value back to DarkBASIC Pro.
SCRIPT FUNCTION STRING script function name (returns a string)
Syntax: stringval$ = script function string("stringval")
Note: Use with functions that return a string back to DarkBASIC Pro.
SCRIPT INT VARIABLE script global variable name (returns a integer)
Syntax: intval = script int variable("some_variable")
Note: To use this function with a variable the variable in the script needs to be declared as global.
SCRIPT FLOAT VARIABLE script global variable name (returns a float)
Syntax: floatval# = script float variable("some_variable")
Note: To use this function with a variable the variable in the script needs to be declared as global.
SCRIPT STRING VARIABLE script global variable name (returns a string)
Syntax: intval = script int variable("some_variable")
Note: To use this function with a variable the variable in the script needs to be declared as global.
SCRIPT SET INT VARIABLE script global variable name, integer value
Syntax: script set int variable "some_variable",521
Note: To use this function with a variable the variable in the script needs to be declared as global.
SCRIPT SET FLOAT VARIABLE script global variable name, float value
Syntax: script set float variable "some_variable",1.213
Note: To use this function with a variable the variable in the script needs to be declared as global.
SCRIPT SET STRING VARIABLE script global variable name, string value
Syntax: script set string variable "some_variable","DarkScript is cool!"
Note: To use this function with a variable the variable in the script needs to be declared as global.
SCRIPT COMPILE TO LIB script file name, script lib name
LOAD LIB SCRIPT lib script file
This early pre-release uses an automated installer, you can download the file by
clicking here.
Check out my site!