ParaScripting::ParaGlobal Class Reference
[ParaGlobal]

List of all members.

Detailed Description

ParaGlobal namespace contains a list of HAPI functions to globally control the engine.


Static Public Member Functions

static void ExitApp ()
 exit the applications.
static void WriteToConsole (const char *strMessage)
 write const char* to console, usually for debugging purposes.
static void WriteToLogFile (const char *strMessage)
 write const char* to log file, usually for debugging purposes.
static int GetLogPos ()
 get the current log file position.
static const char * GetLog (int fromPos, int nCount)
 get log text between two Log positions.
static bool WriteToFile (const char *filename, const char *strMessage)
 write const char* to specific file.
static void SetGameStatus (const char *strState)
 set the game status
static double GetGameTime ()
 
Returns:
return the current game time in milliseconds.When game is paused, game time is also paused.

static const char * GetDateFormat (const char *sFormat)
 get the date in string
static const char * GetTimeFormat (const char *sFormat)
 get the time in string
static DWORD timeGetTime ()
 The timeGetTime function retrieves the system time, in milliseconds.
static double random ()
 the random seed is set at application start
static double GetSysDateTime ()
 Get the system date and time in seconds.
static const char * GenerateUniqueID ()
 generate a unique ID as a string.
static void SaveObject (const char *strObjectName, const object &objObject)
 global object dictionary functions: this is a way for different script runtime to share some global information.
static object LoadObject (const object &strObjectName)
 global object dictionary functions: this is a way for different script runtime to share some global information.
static void SetGameLoop (const char *scriptName)
 reset the game loop script.
static void SetGameLoopInterval (float fInterval)
 set the game loop activation interval.
static bool CreateProcess (const char *lpApplicationName, const char *lpCommandLine, bool bWaitOnReturn)
 run an external application.
static bool ShellExecute (const char *lpOperation, const char *lpFile, const char *lpParameters, const char *lpDirectory, int nShowCmd)
 Performs an operation on a specified file.
static bool WriteRegStr (const string &root_key, const string &sSubKey, const string &name, const string &value)
 Write a string to the registry.
static const char * ReadRegStr (const string &root_key, const string &sSubKey, const string &name)
 Read string from the registry.
static bool WriteRegDWORD (const string &root_key, const string &sSubKey, const string &name, DWORD value)
 Write a DWORD to the registry.
static DWORD ReadRegDWORD (const string &root_key, const string &sSubKey, const string &name)
 Read DWORD from the registry.


Member Function Documentation

int ParaScripting::ParaGlobal::GetLogPos (  )  [static]

get the current log file position.

it is equivalent to the log file size in bytes. one can later get log text between two Log positions.

const char * ParaScripting::ParaGlobal::GetLog ( int  fromPos,
int  nCount 
) [static]

get log text between two Log positions.

Parameters:
fromPos,: position in bytes. if nil, it defaults to 0
nCount,: count in bytes. if nil, it defaults to end of log file.
Returns:
string returned.

bool ParaGlobal::WriteToFile ( const char *  filename,
const char *  strMessage 
) [static]

write const char* to specific file.

obsolete

void ParaGlobal::SetGameStatus ( const char *  strState  )  [static]

set the game status

Parameters:
strState,: 
  • "disable" disable the game
  • "enable" enable the game
  • "pause" pause the game
  • "resume" resume the game

double ParaGlobal::GetGameTime (  )  [static]

Returns:
return the current game time in milliseconds.When game is paused, game time is also paused.

this is usually used for cinematic movies

const char * ParaScripting::ParaGlobal::GetDateFormat ( const char *  sFormat  )  [static]

get the date in string

Parameters:
sFormat,: can be NULL to use default.e.g. "ddd',' MMM dd yy"
  • d Day of month as digits with no leading zero for single-digit days.
  • dd Day of month as digits with leading zero for single-digit days.
  • ddd Day of week as a three-letter abbreviation. The function uses the LOCALE_SABBREVDAYNAME value associated with the specified locale.
  • dddd Day of week as its full name. The function uses the LOCALE_SDAYNAME value associated with the specified locale.
  • M Month as digits with no leading zero for single-digit months.
  • MM Month as digits with leading zero for single-digit months.
  • MMM Month as a three-letter abbreviation. The function uses the LOCALE_SABBREVMONTHNAME value associated with the specified locale.
  • MMMM Month as its full name. The function uses the LOCALE_SMONTHNAME value associated with the specified locale.
  • y Year as last two digits, but with no leading zero for years less than 10.
  • yy Year as last two digits, but with leading zero for years less than 10.
  • yyyy Year represented by full four digits.
  • gg Period/era string. The function uses the CAL_SERASTRING value associated with the specified locale. This element is ignored if the date to be formatted does not have an associated era or period string.

const char * ParaScripting::ParaGlobal::GetTimeFormat ( const char *  sFormat  )  [static]

get the time in string

Parameters:
sFormat,: can be NULL to use default. e.g. "hh':'mm':'ss tt"
  • h Hours with no leading zero for single-digit hours; 12-hour clock.
  • hh Hours with leading zero for single-digit hours; 12-hour clock.
  • H Hours with no leading zero for single-digit hours; 24-hour clock.
  • HH Hours with leading zero for single-digit hours; 24-hour clock.
  • m Minutes with no leading zero for single-digit minutes.
  • mm Minutes with leading zero for single-digit minutes.
  • s Seconds with no leading zero for single-digit seconds.
  • ss Seconds with leading zero for single-digit seconds.
  • t One character time-marker string, such as A or P.
  • tt Multicharacter time-marker string, such as AM or PM.

DWORD ParaScripting::ParaGlobal::timeGetTime (  )  [static]

The timeGetTime function retrieves the system time, in milliseconds.

The system time is the time elapsed since Windows was started. Note that the value returned by the timeGetTime function is a DWORD value. The return value wraps around to 0 every 2^32 milliseconds, which is about 49.71 days. This can cause problems in code that directly uses the timeGetTime return value in computations, particularly where the value is used to control code execution. You should always use the difference between two timeGetTime return values in computations.

double ParaScripting::ParaGlobal::random (  )  [static]

the random seed is set at application start

Returns:
generate a random number between [0,1]

double ParaScripting::ParaGlobal::GetSysDateTime (  )  [static]

Get the system date and time in seconds.

The system time is expressed in Coordinated Universal Time (UTC). Note: there is some trick to make the returned value a valid number in NPL. Only compare time with time returned by the same function. TODO: in the long run, a true unsigned int64 should be returned.

const char * ParaScripting::ParaGlobal::GenerateUniqueID (  )  [static]

generate a unique ID as a string.

This is usually a string.

Returns:

void ParaGlobal::SaveObject ( const char *  strObjectName,
const object &  objObject 
) [static]

global object dictionary functions: this is a way for different script runtime to share some global information.

Currently only value and const char* object can be saved. one can save nil to a object name to delete the object.

Parameters:
objObject,: object to save

already exists, then override old value

already exists, then override old value

already exists, delete it.

object ParaGlobal::LoadObject ( const object &  strObjectName  )  [static]

global object dictionary functions: this is a way for different script runtime to share some global information.

Currently only value and const char* object can be saved. return nil, if object is not found

Parameters:
strObjectName,: the object name

get object from dictionary table

void ParaGlobal::SetGameLoop ( const char *  scriptName  )  [static]

reset the game loop script.

the game loop script will be activated every 0.5 seconds see SetGameLoopInterval() to change the default interval Please keep the game loop concise. The default game loop is ./script/gameinterface.lua

void ParaGlobal::SetGameLoopInterval ( float  fInterval  )  [static]

set the game loop activation interval.

The default value is 0.5 seconds.

bool ParaGlobal::CreateProcess ( const char *  lpApplicationName,
const char *  lpCommandLine,
bool  bWaitOnReturn 
) [static]

run an external application.

creates a new process and its primary thread. The new process runs the specified executable file in the security context of the calling process.

Remarks:
: One can also use ParaEngine C++ or .Net API to write application plug-ins for the game engine, which can be loaded like any other script files. e.g. To open a file in an external notepad editor use ParaGlobal.CreateProcess("c:\\notepad.exe", "\"c:\notepad.exe\" c:\\test.txt", true);
Parameters:
lpApplicationName:Pointer to a null-terminated string that specifies the module to execute. The specified module can be a Windows-based application. The string can specify the full path and file name of the module to execute or it can specify a partial name. In the case of a partial name, the function uses the current drive and current directory to complete the specification. The function will not use the search path. If the file name does not contain an extension, .exe is assumed. If the executable module is a 16-bit application, lpApplicationName should be NULL, and the string pointed to by lpCommandLine should specify the executable module as well as its arguments.
lpCommandLine:Pointer to a null-terminated string that specifies the command line to execute.
bWaitOnReturn,: if false, the function returns immediately; otherwise it will wait for the editor to return. if this is true, the Child Process will have Redirected Input and Output to current log file.
Returns:
true if opened.

bool ParaGlobal::ShellExecute ( const char *  lpOperation,
const char *  lpFile,
const char *  lpParameters,
const char *  lpDirectory,
int  nShowCmd 
) [static]

Performs an operation on a specified file.

e.g. ParaGlobal.ShellExecute("open", "iexplore.exe", "http://www.paraengine.com", nil, 1);

Parameters:
lpOperation:[in] Pointer to a null-terminated string,
  • "edit" Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.
  • "explore" Explores the folder specified by lpFile.
  • "find" Initiates a search starting from the specified directory.
  • "open" Opens the file specified by the lpFile parameter. The file can be an executable file, a document file, or a folder.
  • "print" Prints the document file specified by lpFile. If lpFile is not a document file, the function will fail.
  • NULL For systems prior to Microsoft Windows 2000, the default verb is used if it is valid and available in the registry. If not, the "open" verb is used.
lpFile [in] Pointer to a null-terminated string that specifies the file or object on which to execute the specified verb. To specify a Shell namespace object, pass the fully qualified parse name. Note that not all verbs are supported on all objects. For example, not all document types support the "print" verb.
lpParameters[in] If the lpFile parameter specifies an executable file, lpParameters is a pointer to a null-terminated string that specifies the parameters to be passed to the application. The format of this string is determined by the verb that is to be invoked. If lpFile specifies a document file, lpParameters should be NULL.
lpDirectory [in] Pointer to a null-terminated string that specifies the default directory.
nShowCmd,: [in] Flags that specify how an application is to be displayed when it is opened. If lpFile specifies a document file, the flag is simply passed to the associated application. It is up to the application to decide how to handle it.
  • define SW_HIDE 0
  • define SW_NORMAL 1
  • define SW_MAXIMIZE 3
  • define SW_SHOW 5
  • define SW_MINIMIZE 6
  • define SW_RESTORE 9

bool ParaScripting::ParaGlobal::WriteRegStr ( const string &  root_key,
const string &  sSubKey,
const string &  name,
const string &  value 
) [static]

Write a string to the registry.

e.g. WriteRegStr("HKLM", "Software\My Company\My Software", "String Value", "String Name");

Parameters:
root_key,: must be HKCR or HKEY_CLASSES_ROOT HKLM or HKEY_LOCAL_MACHINE HKCU or HKEY_CURRENT_USER HKU or HKEY_USERS

const char * ParaScripting::ParaGlobal::ReadRegStr ( const string &  root_key,
const string &  sSubKey,
const string &  name 
) [static]

Read string from the registry.

Valid values for root_key are listed under WriteRegStr. NULL will be returned if the string is not present. If the value is present, but is of type REG_DWORD, it will be read and converted to a string.

Parameters:
root_key,: must be HKCR or HKEY_CLASSES_ROOT HKLM or HKEY_LOCAL_MACHINE HKCU or HKEY_CURRENT_USER HKU or HKEY_USERS

bool ParaScripting::ParaGlobal::WriteRegDWORD ( const string &  root_key,
const string &  sSubKey,
const string &  name,
DWORD  value 
) [static]

Write a DWORD to the registry.

see WriteRegStr() for more info

Parameters:
root_key,: must be HKCR or HKEY_CLASSES_ROOT HKLM or HKEY_LOCAL_MACHINE HKCU or HKEY_CURRENT_USER HKU or HKEY_USERS

DWORD ParaScripting::ParaGlobal::ReadRegDWORD ( const string &  root_key,
const string &  sSubKey,
const string &  name 
) [static]

Read DWORD from the registry.

Valid values for root_key are listed under WriteRegStr. NULL will be returned if the DWORD is not present or type is a string.

Parameters:
root_key,: must be HKCR or HKEY_CLASSES_ROOT HKLM or HKEY_LOCAL_MACHINE HKCU or HKEY_CURRENT_USER HKU or HKEY_USERS


Generated on Mon Dec 1 14:34:47 2008 for NPL Scripting Reference for ParaEngine by  doxygen 1.5.2