IScriptSystem

Scripting Engine interface.

C++
struct IScriptSystem {
};
File

IScriptSystem.h

Description

This interface is mapped 1:1 on a script state. All scripts loaded from the same interface instance are visible with each others.

IScriptSystem::~IScriptSystem Destructor
C++
virtual ~IScriptSystem();
IScriptSystem::AddBreakPoint Method
C++
virtual HBREAKPOINT AddBreakPoint(const char * sFile, int nLineNumber) = 0;
IScriptSystem::AddFuncRef Method
C++
virtual HSCRIPTFUNCTION AddFuncRef(HSCRIPTFUNCTION f) = 0;
Description

Adds new reference to function referenced by HSCRIPTFUNCTION.

See Also
IScriptSystem::Allocate Method

Allocate or deallocate through the script system's allocator

C++
virtual void* Allocate(size_t sz) = 0;
IScriptSystem::BeginCall Method (HSCRIPTFUNCTION)

Calls a named method inside specified table.

C++
virtual int BeginCall(HSCRIPTFUNCTION hFunc) = 0;
Description

Márcio: changed the return type .

IScriptSystem::BeginCall Method (IScriptTable *, char *)
C++
virtual int BeginCall(IScriptTable * pTable, const char * sFuncName) = 0;
IScriptSystem::BeginCall Method (char *)
C++
virtual int BeginCall(const char * sFuncName) = 0;
Description

From void to int for error checking.

IScriptSystem::BeginCall Method (char *, char *)

Calls a named method inside specified table.

C++
virtual int BeginCall(const char * sTableName, const char * sFuncName) = 0;
IScriptSystem::BeginPreCachedBuffer Method
C++
virtual int BeginPreCachedBuffer(int iIndex) = 0;
IScriptSystem::ClearPreCachedBuffer Method
C++
virtual void ClearPreCachedBuffer() = 0;
IScriptSystem::CloneAny Method
C++
virtual ScriptAnyValue CloneAny(const ScriptAnyValue& any) = 0;
Description

Properly clones a ScriptAnyValue. It will create new references to objects if appropriate.

IScriptSystem::CompareFuncRef Method
C++
virtual bool CompareFuncRef(HSCRIPTFUNCTION f1, HSCRIPTFUNCTION f2) = 0;
Description

Adds new reference to function referenced by HSCRIPTFUNCTION.

See Also
IScriptSystem::CompileBuffer Method

Facility to pre-catch any Lua buffer.

C++
virtual HSCRIPTFUNCTION CompileBuffer(const char * sBuffer, size_t nSize, const char* sBufferDesc) = 0;
IScriptSystem::CreateTable Method

Creates a new IScriptTable table accessible to the scripts.

C++
virtual IScriptTable* CreateTable(bool bEmpty = false) = 0;
Returns

A pointer to the created object, with the reference count of 0.

See Also
IScriptSystem::CreateUserData Method
C++
virtual IScriptTable * CreateUserData(void * ptr, size_t size) = 0;
IScriptSystem::Deallocate Method
C++
virtual size_t Deallocate(void* ptr) = 0;
IScriptSystem::DebugContinue Method
C++
virtual void DebugContinue() = 0;
IScriptSystem::DebugDisable Method
C++
virtual void DebugDisable() = 0;
IScriptSystem::DebugStepInto Method
C++
virtual void DebugStepInto() = 0;
IScriptSystem::DebugStepNext Method
C++
virtual void DebugStepNext() = 0;
IScriptSystem::DumpCallStack Method
C++
virtual void DumpCallStack() = 0;
Description

dump callstack to log, can be used during exception handling

IScriptSystem::DumpLoadedScripts Method

Generates a OnLoadedScriptDump() for every loaded script.

C++
virtual void DumpLoadedScripts() = 0;
IScriptSystem::EndCall Method ()

Ends a call to script function.

C++
virtual bool EndCall() = 0;
IScriptSystem::EndCall Method (T &)
C++
template <class T> bool EndCall(T & value);
IScriptSystem::EndCallAny Method
C++
virtual bool EndCallAny(ScriptAnyValue & any) = 0;
IScriptSystem::EndCallAnyN Method
C++
virtual bool EndCallAnyN(int n, ScriptAnyValue* anys) = 0;
IScriptSystem::ExecuteBuffer Method

Executes an ASCII buffer.

C++
virtual bool ExecuteBuffer(const char * sBuffer, size_t nSize, const char * sBufferDescription = "", IScriptTable* pEnv = 0) = 0;
Parameters
Parameters
Description
const char * sBuffer
An 8bit ASCII buffer containing the script that must be executed.
const char * sBufferDescription = ""
Used as a name to describe the buffer.
bRaiseError
When set to true, the script engine will call CryWarning when an error in the script file occurs.
Returns

False if the execution fails, otherwise it will be true.

Remarks

All global variables and functions declared in the executed script will persist for all the script system lifetime.

IScriptSystem::ExecuteFile Method

Loads and runs a script file.

C++
virtual bool ExecuteFile(const char * sFileName, bool bRaiseError = true, bool bForceReload = false, IScriptTable* pEnv = 0) = 0;
Parameters
Parameters
Description
const char * sFileName
Path of the script file.
bool bRaiseError = true
When set to true, the script engine will call CryWarning when an error in the script file occurs.
Returns

False if the execution fails, otherwise it will be true.

Remarks

All global variables and functions declared in the executed script will persist for all the script system lifetime.

IScriptSystem::ForceGarbageCollection Method
C++
virtual void ForceGarbageCollection() = 0;
Description

Forces a Garbage collection cycle. Notes: In the current status of the engine the automatic GC is disabled so this function must be called explicitly.

IScriptSystem::GetBreakState Method
C++
virtual BreakState GetBreakState() = 0;
IScriptSystem::GetCallsStack Method
C++
virtual IScriptTable * GetCallsStack() = 0;
Description

[1]={ description="function bau()", line=234, sourcefile="/scripts/bla/bla/bla.lua"

IScriptSystem::GetCGCount Method

Gets number of "garbaged" object.

C++
virtual int GetCGCount() = 0;
IScriptSystem::GetEnvironment Method

Gets the environment of the given function

C++
virtual IScriptTable* GetEnvironment(HSCRIPTFUNCTION scriptFunction) = 0;
Parameters
Parameters
Description
HSCRIPTFUNCTION scriptFunction
Function to receive the environment
Returns

Pointer to a script table containing the environment

IScriptSystem::GetFunctionPtr Method (char *)
C++
virtual HSCRIPTFUNCTION GetFunctionPtr(const char * sFuncName) = 0;
Description

Gets reference to the Lua function. Notes: This reference must be released with IScriptSystem::ReleaseFunc().

See Also
IScriptSystem::GetFunctionPtr Method (char *, char *)
C++
virtual HSCRIPTFUNCTION GetFunctionPtr(const char * sTableName, const char * sFuncName) = 0;
IScriptSystem::GetGlobalAny Method
C++
virtual bool GetGlobalAny(const char * sKey, ScriptAnyValue & any) = 0;
Description

Get Global value.

IScriptSystem::GetGlobalValue Method
C++
template <class T> bool GetGlobalValue(const char * sKey, T & value);
Description

Get Global value.

IScriptSystem::GetLocalVariables Method
C++
virtual IScriptTable * GetLocalVariables(int nLevel = 0) = 0;
IScriptSystem::GetMemoryStatistics Method
C++
virtual void GetMemoryStatistics(ICrySizer * pSizer) const = 0;
IScriptSystem::GetScriptAllocSize Method

Retrieves size of memory allocated in script.

C++
virtual uint32 GetScriptAllocSize() = 0;
IScriptSystem::GetScriptHash Method
C++
virtual void GetScriptHash(const char * sPath, const char * szKey, unsigned int & dwHash) = 0;
Parameters
Parameters
Description
const char * sPath
Zero terminated path to the variable (e.g. _localplayer.cnt), max 255 characters.
const char * szKey
Zero terminated name of the variable (e.g. luaFunc), max 255 characters.
unsigned int & dwHash
It is used as input and output.
Description

Notes: Is not recursive but combines the hash values of the whole table when the specifies variable is a table otherwise has to be a Lua function.

IScriptSystem::GetStackSize Method
C++
virtual int GetStackSize() = 0;
IScriptSystem::LoadScriptedSurfaceTypes Method
C++
virtual void LoadScriptedSurfaceTypes(const char * sFolder, bool bReload) = 0;
IScriptSystem::PostInit Method
C++
virtual void PostInit() = 0;
Description

Notes: Called one time after initialization of system to register script system console vars.

IScriptSystem::PreCacheBuffer Method
C++
virtual int PreCacheBuffer(const char * sBuffer, size_t nSize, const char* sBufferDesc) = 0;
IScriptSystem::PushFuncParam Method
C++
template <class T> void PushFuncParam(const T & value);
IScriptSystem::PushFuncParamAny Method
C++
virtual void PushFuncParamAny(const ScriptAnyValue & any) = 0;
Description

Push a parameter during a function call.

IScriptSystem::RaiseError Method
C++
virtual void RaiseError(const char * format, ...);
IScriptSystem::Release Method

Releases and destroys the script system.

C++
virtual void Release() = 0;
IScriptSystem::ReleaseAny Method
C++
virtual void ReleaseAny(const ScriptAnyValue& any) = 0;
Description

Properly releases a ScriptAnyValue. It will release references to objects if appropriate.

IScriptSystem::ReleaseFunc Method
C++
virtual void ReleaseFunc(HSCRIPTFUNCTION f) = 0;
Description

Frees references created with GetFunctionPtr or GetValue for HSCRIPTFUNCTION.

See Also
IScriptSystem::ReloadScript Method

Reloads a script.

C++
virtual bool ReloadScript(const char * sFileName, bool bRaiseError = true) = 0;
Parameters
Parameters
Description
const char * sFileName
Path of the script file to reload.
bool bRaiseError = true
When set to true, the script engine will call CryWarning when an error in the script file occurs.
Returns

False if the execution fails, otherwise it will be true.

See Also
IScriptSystem::ReloadScripts Method

Reloads all the scripts previously loaded.

C++
virtual bool ReloadScripts() = 0;
Returns

False if the execution of one of the script fails, otherwise it will be true.

IScriptSystem::ResetTimers Method

Resets all the script timers.

C++
virtual void ResetTimers() = 0;
IScriptSystem::SerializeTimers Method

Serializes script timers.

C++
virtual void SerializeTimers(ISerialize * pSer) = 0;
IScriptSystem::SetEnvironment Method

Sets the environment of the given function

C++
virtual void SetEnvironment(HSCRIPTFUNCTION scriptFunction, IScriptTable* pEnv) = 0;
Parameters
Parameters
Description
HSCRIPTFUNCTION scriptFunction
Function to receive the environment
IScriptTable* pEnv
Environment to set
IScriptSystem::SetGCFrequency Method

Sets the rate of Garbage Collection for script system.

C++
virtual void SetGCFrequency(const float fRate) = 0;
Parameters
Parameters
Description
const float fRate
The rate in seconds.
IScriptSystem::SetGCThreshhold Method
C++
virtual void SetGCThreshhold(int nKb) = 0;
Notes

Legacy function.

IScriptSystem::SetGlobalAny Method
C++
virtual void SetGlobalAny(const char * sKey, const ScriptAnyValue & any) = 0;
Description

Set Global value.

IScriptSystem::SetGlobalToNull Method
C++
virtual void SetGlobalToNull(const char * sKey);
Description

Set Global value to Null.

IScriptSystem::SetGlobalValue Method
C++
template <class T> void SetGlobalValue(const char * sKey, const T & value);
Description

Set Global value.

IScriptSystem::ShowDebugger Method
C++
virtual void ShowDebugger(const char * pszSourceFile, int iLine, const char * pszReason) = 0;
Description

Notes: Debug functions.

IScriptSystem::UnloadScript Method
C++
virtual void UnloadScript(const char * sFileName) = 0;
Parameters
Parameters
Description
const char * sFileName
Path of the script file.
Description

Unloads a script.

Remarks

The script engine never loads twice the same file because it internally stores a list of the loaded files. Calling this functions will remove the script file from this list.

See Also
IScriptSystem::UnloadScripts Method

Unloads all the scripts.

C++
virtual void UnloadScripts() = 0;
Remarks
IScriptSystem::Update Method

Updates the system, per frame.

C++
virtual void Update() = 0;