ParaScripting::ParaWorld Class Reference
[ParaWorld]

List of all members.

Detailed Description

world creation functions.


Static Public Member Functions

static string NewWorld (const char *sWorldName, const char *sBaseWorldName)
 created a new empty world based on a given world.
static const char * NewWorld_ (const char *sWorldName, const char *sBaseWorldName)
 solely used for exporting
static void DeleteWorld (const char *sWorldName)
 delete a given world.
static string NewEmptyWorld (const char *sWorldName=NULL, float fTileSize=533.3333f, int nTileDimension=64)
 Create an empty world, with flat land.
static const char * NewEmptyWorld_ (const char *sWorldName=NULL, float fTileSize=533.3333f, int nTileDimension=64)
 solely used for exporting
static void SetEnablePathEncoding (bool bEnable)
 set whether we will encode world related files.
static bool GetEnablePathEncoding ()
 get whether we will encode world related files.
static ParaDataProvider GetNpcDB ()
 get the current NPC data provider.
static void GetNpcDB_ (ParaDataProvider *out)
 solely used for exporting
static void SetNpcDB (const char *sConnectionstring)
 set the global NPC data base to a new database file.
static ParaDataProvider GetAttributeProvider ()
 get the current attribute data provider.
static void GetAttributeProvider_ (ParaDataProvider *out)
 solely used for exporting
static void SetAttributeProvider (const char *sConnectionstring)
 set the current attribute data base to a new database file.
static void SetWorldDB (const char *sConnectionstring)
 set world database.
static string GetStringbyID (int ID)
 Get string from ID.
static int InsertString (const char *strEN, const char *strCN)
 Insert the new string table entry to StringTable_DB.
static void SetServerState (int nState)
 set the current server state.
static int GetServerState ()
static bool SendTerrainUpdate (const char *sDestination, float center_x, float center_y, float center_z, float fRadius, float fResolution)
 Call this function to send a copy of the local terrain to a destination world at a given resolution.
static string GetWorldName ()
 get current world name
static string GetWorldDirectory ()
 get world root path.
static void SetScriptSandBox (const char *sSandboxNeuronFile)
 Paraworld is told to execute in the given sandbox.
static const char * GetScriptSandBox ()
 please see SetScriptSandBox()


Member Function Documentation

static string ParaScripting::ParaWorld::NewWorld ( const char *  sWorldName,
const char *  sBaseWorldName 
) [static]

created a new empty world based on a given world.

This is like class inheritance in C++ another world could derive from a given world, overriding certain terrain tile contents as it evolves. One can immediately create the new world which is identical to the base world. Every changes made to the new world will be saved in the new world folder and will not affect the base world. in reality, we just copy the base world's world config file to the new world using the new world's name. e.g
local sConfigFileName = ParaWorld.NewWorld("__TmpWorld", "sample/worldconfig.txt");
if(sConfigFileName ~= "") then
ParaScene.CreateWorld("", 32000, sConfigFileName);
end
NOTE: if the sWorldName is the same as sBaseWorldName, the sBaseWorldName itself will be overridden

Parameters:
sWorldName,: world name, a directory with the same name will be created containing the world config file.
sBaseWorldName,: any valid world config file.
Returns:
: return the world config file. if failed, return ""

static void ParaScripting::ParaWorld::DeleteWorld ( const char *  sWorldName  )  [static]

delete a given world.

static string ParaScripting::ParaWorld::NewEmptyWorld ( const char *  sWorldName = NULL,
float  fTileSize = 533.3333f,
int  nTileDimension = 64 
) [static]

Create an empty world, with flat land.

Parameters:
sWorldName,: world name, if NULL, it defaults to "_emptyworld"
fTileSize,: terrain tile size in meters
nTileDimension,: dimension of the tile matrix. default is 64, which is has 64*64 tiles

static void ParaScripting::ParaWorld::SetEnablePathEncoding ( bool  bEnable  )  [static]

set whether we will encode world related files.

default to true. By enabling path encoding, world related files like "worlddir/worldfile.txt" will be saved as "%WORLD%/worldfile.txt", thus even the entire world directory changes, the world files can still be found using path variables. Path encoding needs to be disabled when you are creating a template world.

static bool ParaScripting::ParaWorld::GetEnablePathEncoding (  )  [static]

get whether we will encode world related files.

default to true. By enabling path encoding, world related files like "worlddir/worldfile.txt" will be saved as "%WORLD%/worldfile.txt", thus even the entire world directory changes, the world files can still be found using path variables. Path encoding needs to be disabled when you are creating a template world.

static ParaDataProvider ParaScripting::ParaWorld::GetNpcDB (  )  [static]

get the current NPC data provider.

static void ParaScripting::ParaWorld::SetNpcDB ( const char *  sConnectionstring  )  [static]

set the global NPC data base to a new database file.

Parameters:
sConnectionstring : currently it is the file path of the database file.

static ParaDataProvider ParaScripting::ParaWorld::GetAttributeProvider (  )  [static]

get the current attribute data provider.

static void ParaScripting::ParaWorld::SetAttributeProvider ( const char *  sConnectionstring  )  [static]

set the current attribute data base to a new database file.

Parameters:
sConnectionstring : currently it is the file path of the database file.

static void ParaScripting::ParaWorld::SetWorldDB ( const char *  sConnectionstring  )  [static]

set world database.

it sets attribute provider, NPC database, etc to the same database file.

Parameters:
sConnectionstring : currently it is the file path of the database file.

static string ParaScripting::ParaWorld::GetStringbyID ( int  ID  )  [static]

Get string from ID.

Parameters:
ID,: ID in kids db's string table.
Returns:
string in the current game language

static int ParaScripting::ParaWorld::InsertString ( const char *  strEN,
const char *  strCN 
) [static]

Insert the new string table entry to StringTable_DB.

Parameters:
str,: Entry in the current game language
Returns:
ID of the inserted string

static void ParaScripting::ParaWorld::SetServerState ( int  nState  )  [static]

set the current server state.

default value is 0. enum CurrentState { STATE_STAND_ALONE = 0, STATE_SERVER, STATE_CLIENT, };

static bool ParaScripting::ParaWorld::SendTerrainUpdate ( const char *  sDestination,
float  center_x,
float  center_y,
float  center_z,
float  fRadius,
float  fResolution 
) [static]

Call this function to send a copy of the local terrain to a destination world at a given resolution.

Parameters:
sDestination a destination namespace, it could be "all@server" or "@server", etc. This will be used to fill the destination address of the packet to be sent.
center_x center of the terrain region to send
center_y center of the terrain region to send
center_z center of the terrain region to send
fRadius radius of the terrain region to send
fResolution if this is 1.f, the local world terrain grid resolution is used.
Returns:

static string ParaScripting::ParaWorld::GetWorldDirectory (  )  [static]

get world root path.

suppose the given world name is "sample". The generated file name is "sample/"

static void ParaScripting::ParaWorld::SetScriptSandBox ( const char *  sSandboxNeuronFile  )  [static]

Paraworld is told to execute in the given sandbox.

(1) ParaWorld namespace supports a sandbox mode, which can be turned on and off on demand. Once turned on, all scripts from the current game world will be executed in a separate and newly created script runtime environment. (2) Sandbox mode is an isolated mode that does not have any link with the glia file environment. (3) The world scripts protected by the sandbox runtime environment includes: terrain tile onload script, biped event handler scripts, such as character onload, onclick events. (4) The sandbox environment includes the following functions that could be used: ParaScene, ParaUI namespace functions. It also explicitly disabled the following functions: a) Dofile() b) Io, ParaIO, Exec c) Require(),NPL.load, NPL.activate, NPL.download: cut off any way to manually load a file. It adds d) Log e) Download some file to replace local file. f) Changing the Enter sand box function or almost any function to some fake function. (5) The following attack methods should be prevented by the sandbox environment a) Execute or load any external application b) Write to any file, including log file c) Compromise data or functions in the glia file environment. Such as, changing and hooking the string method d) Compromise the sandbox itself and then affect in the next sandbox entity. (6) glia file environment does not have a sandbox mode. Because I found that any global sandbox mode implementation has a way to hack in, and I give up any measure of protecting the glia file environment. Sandbox protection for the world file is enough because that is the only source file that may not be provided by ParaEngine. In order to run any other code not provided by the ParaEngine, the user should have been well informed of the danger. But so far, there is no need to have a world that should inform the user. Because most world functions are supported in the world sandbox.

Parameters:
sNeuronFileName,: script file name. Use NPL.CreateNeuronFile() to create a sandbox neuron file if you do not want to use a sandbox, please specify NULL or "".

static const char* ParaScripting::ParaWorld::GetScriptSandBox (  )  [static]

please see SetScriptSandBox()

Returns:
: it may return NULL if the sandbox does not exist.


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