Well I'm the one who posted this over on the game programming board.
I will explain.
The 'global script' is the script that is read by your program at the start of the game. Essentially in game design theory the engine itself is not the game...it is just the code that executes the game.
The game 'data' is the game. The script is really where the true game is and your engine just acts on the script. At the start of the game you would compile the entire script into static code structures that would be checked periodically. Here might be an example.
Code:
struct Vector3
{
float x,y,z;
//....
//add more code as needed
};
class Unit
{
//Position
Vector3 Position;
//Velocity vector
Vector3 Velocity;
//Rotation (facing)
Vector3 Rotation;
public:
Unit() {}
void Kill(void);
void SetTarget(Unit *target);
//more functions related to unit manipulation
};
//Defines an action for an event
class Action
{
//Allows several actions to be fired off by one or more
//conditionals
Action *NextAction;
Unit *UnitPtr;
public:
Action() {UnitPtr=NULL;};
void Attach(Unit *unit) {UnitPtr=unit;};
void Kill(void) {UnitPtr->Kill();};
void ToUnit(Unit *target) {UnitPtr->SetTarget(target);};
};
class Condition
{
//Allows you to specify several conditions to activate event(s)
Condition *NextCondition;
int m_iCondType;
public:
Condition() {}
//add code
};
class Event
{
Action *ActionPtr;
Condition *ConditionPtr;
//Is this event firing?
bool m_bActive;
//How many times has this event fired?
int m_iNumTimesFired;
//How many seconds have elapsed since the last time this
//event fired?
int m_iElapsed;
public:
Event():ActionPtr(NULL),ConditionPtr(NULL) {}
//Bind this event to a condition and an action or series of
//actions
void Create(Condition *condptr,Action *actionptr);
//Will test condition, if true, will fire event and return true -
//else will return false
bool IsTrue(void);
};
Now I've just showed a simple skeleton of a basic scripting engine. So now let me demonstrate by using Novalogic's WAC script for Joint Operations and their Delta Force series.
Code:
if Elapsed(20) and Never() then
SSNKill(66557)
SSNKill(66558)
SSN2SSN(66559,66700)
farflash()
endif
What this means is:
Code:
IF 20 seconds have elapsed since this even last fired
AND
this event has NEVER fired before
THEN
kill unit with ID of 66557
kill unit with ID of 66558
move unit with ID of 66559 to unit with ID of 66700
create a far flash of lighting
ENDIF
So if you use this scripting language then you know what objects you need to create when you read the script.
You need an event that tests for 20 seconds having elapsed. This would be a simple check of the iElapsed member of the class. Return true if 20 seconds have elapsed.
Code:
if (Event->Elapsed(20) && Event->HasNeverFired())
{
//Perform actions
}
All you are doing is turning the script language into C++ code at load time.
It can get quite complex but using the robust features of CString and or std::string you will be able to produce some pretty fancy scripting languages with little effort.
You could also write a class to handle user variables. No names or anything just stuff like this:
VarSET(1,1)
This would set variable 1 to a value of 1.
Then VarTEST(1,1) would return true if Variable 1 was equal to 1.
This would be a simple class that held information about 255 or 65535 variables. Your choice.
Code:
class CScriptVars
{
unsigned int m_uintVars[255];
public:
CScriptVars(void) {memset(m_uintVars,0,sizeof(unsigned int));};
bool VarTEST(unsigned int varnum,unsigned int value)
{
return (m_uintVars[varnum]==value);
}
void VarSET(unsigned int varnum,unsigned int value)
{
m_uintVars[varnum]=value;
}
//add more tests and arithmetic if needed
};
With this simple setup you could produce virtually anything you want -totally separate from the game engine. This is the key point. Keep the game data out of the game engine.
I know this was long....but I hope it helped.