Namespace: dmScript
Language: C++
Type: Defold C++
File: script.h
Source: engine/script/src/dmsdk/script/script.h
Include: dmsdk/script/script.h
Built-in scripting functions.
Type: FUNCTION Check if the value in the supplied index on the lua stack is a hash.
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
value (hash) - The hash valueType: FUNCTION Check if the value in the supplied index on the lua stack is a hash.
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
value (hash) - The hash valueType: FUNCTION Check if the value in the supplied index on the lua stack is a hash or string. If it is a string, it gets hashed on the fly
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
value (hash) - The hash valueType: FUNCTION Check if the value in the supplied index on the lua stack is a hash or string. If it is a string, it gets hashed on the fly
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
value (hash) - The hash valueType: FUNCTION Check if the value in the supplied index on the lua stack is a dmVMath::Matrix4.
Notes
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
matrix (dmVMath::Matrix4*) - The pointer to the valueType: FUNCTION Check if the value in the supplied index on the lua stack is a dmVMath::Matrix4.
Notes
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
matrix (dmVMath::Matrix4*) - The pointer to the valueType: FUNCTION Check if the value in the supplied index on the lua stack is a dmVMath::Quat.
Notes
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
quat (dmVMath::Quat*) - The pointer to the valueType: FUNCTION Check if the value in the supplied index on the lua stack is a dmVMath::Quat.
Notes
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
quat (dmVMath::Quat*) - The pointer to the valueType: FUNCTION Serialize a table to a buffer Supported types: LUA_TBOOLEAN, LUA_TNUMBER, LUA_TSTRING, Point3, Vector3, Vector4 and Quat Keys must be strings
Parameters
L (lua_State*) - Lua statebuffer (char*) - Buffer that will be written to (must be DM_ALIGNED(16))buffer_size (uint32_t) - Buffer sizeindex (int) - Index of the tableReturns
result (uint32_t) - Number of bytes used in bufferType: FUNCTION Serialize a table to a buffer Supported types: LUA_TBOOLEAN, LUA_TNUMBER, LUA_TSTRING, Point3, Vector3, Vector4 and Quat Keys must be strings
Parameters
L (lua_State*) - Lua statebuffer (char*) - Buffer that will be written to (must be DM_ALIGNED(16))buffer_size (uint32_t) - Buffer sizeindex (int) - Index of the tableReturns
result (uint32_t) - Number of bytes used in bufferType: FUNCTION Check if the value in the supplied index on the lua stack is a dmMessage::URL and returns it if so.
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
url (dmMessage::URL*) - The pointer to the valueType: FUNCTION Get the current game object URL
Parameters
L (lua_State*) - Lua stateout_url (dmMessage::URL*) - where to store the resultReturns
result (bool) - true if successfulType: FUNCTION Check if the value in the supplied index on the lua stack is a dmMessage::URL and returns it if so.
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
url (dmMessage::URL*) - The pointer to the valueType: FUNCTION Get the current game object URL
Parameters
L (lua_State*) - Lua stateout_url (dmMessage::URL*) - where to store the resultReturns
result (bool) - true if successfulType: FUNCTION Check if the value in the supplied index on the lua stack is a dmVMath::Vector3.
Notes
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
vector3 (dmVMath::Vector3*) - The pointer to the valueType: FUNCTION Check if the value in the supplied index on the lua stack is a dmVMath::Vector3.
Notes
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
vector3 (dmVMath::Vector3*) - The pointer to the valueType: FUNCTION Check if the value in the supplied index on the lua stack is a dmVMath::Vector3.
Notes
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
vector4 (dmVMath::Vector4*) - The pointer to the valueType: FUNCTION Check if the value in the supplied index on the lua stack is a dmVMath::Vector3.
Notes
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
vector4 (dmVMath::Vector4*) - The pointer to the valueType: FUNCTION Stores the current Lua state plus references to the script instance (self) and the callback. Expects SetInstance() to have been called prior to using this method. The allocated data is created on the Lua stack and references are made against the instances own context table. If the callback is not explicitly deleted with DestroyCallback() the references and data will stay around until the script instance is deleted.
Parameters
L (lua_State*) - Lua stateindex (int) - Lua stack index of the functionReturns
callback (LuaCallbackInfo*) - Lua callback struct if successful, 0 otherwiseExamples
static int SomeFunction(lua_State* L) // called from Lua
{
LuaCallbackInfo* cbk = dmScript::CreateCallback(L, 1);
... store the callback for later
}
static void InvokeCallback(LuaCallbackInfo* cbk)
{
lua_State* L = dmScript::GetCallbackLuaContext(cbk);
DM_LUA_STACK_CHECK(L, 0);
if (!dmScript::SetupCallback(callback))
{
return;
}
lua_pushstring(L, "hello");
dmScript::PCall(L, 2, 0); // self + # user arguments
dmScript::TeardownCallback(callback);
dmScript::DestroyCallback(cbk); // only do this if you're not using the callback again
}
Type: FUNCTION Stores the current Lua state plus references to the script instance (self) and the callback. Expects SetInstance() to have been called prior to using this method. The allocated data is created on the Lua stack and references are made against the instances own context table. If the callback is not explicitly deleted with DestroyCallback() the references and data will stay around until the script instance is deleted.
Parameters
L (lua_State*) - Lua stateindex (int) - Lua stack index of the functionReturns
callback (LuaCallbackInfo*) - Lua callback struct if successful, 0 otherwiseExamples
static int SomeFunction(lua_State* L) // called from Lua
{
LuaCallbackInfo* cbk = dmScript::CreateCallback(L, 1);
... store the callback for later
}
static void InvokeCallback(LuaCallbackInfo* cbk)
{
lua_State* L = dmScript::GetCallbackLuaContext(cbk);
DM_LUA_STACK_CHECK(L, 0);
if (!dmScript::SetupCallback(callback))
{
return;
}
lua_pushstring(L, "hello");
dmScript::PCall(L, 2, 0); // self + # user arguments
dmScript::TeardownCallback(callback);
dmScript::DestroyCallback(cbk); // only do this if you're not using the callback again
}
Type: FUNCTION Deletes the Lua callback
Parameters
cbk (LuaCallbackInfo*) - Lua callback structType: FUNCTION Deletes the Lua callback
Parameters
cbk (LuaCallbackInfo*) - Lua callback structType: MACRO This macro will verify that the Lua stack size hasn’t been changed before throwing a Lua error, which will long-jump out of the current function. This macro can only be used together with DM_LUA_STACK_CHECK and should be prefered over manual checking of the stack.
Parameters
fmt (const char*) - Format string that contains error information.args (…) - Format string args (variable arg list)Examples
static int ModuleFunc(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 1);
if (some_error_check(L))
{
return DM_LUA_ERROR("some error message");
}
lua_pushnumber(L, 42);
return 1;
}
Type: MACRO This macro will verify that the Lua stack size hasn’t been changed before throwing a Lua error, which will long-jump out of the current function. This macro can only be used together with DM_LUA_STACK_CHECK and should be prefered over manual checking of the stack.
Parameters
fmt (const char*) - Format string that contains error information.args (…) - Format string args (variable arg list)Examples
static int ModuleFunc(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 1);
if (some_error_check(L))
{
return DM_LUA_ERROR("some error message");
}
lua_pushnumber(L, 42);
return 1;
}
Type: MACRO Diff is the expected difference of the stack size. If luaL_error, or another function that executes a long-jump, is part of the executed code, the stack guard cannot be guaranteed to execute at the end of the function. In that case you should manually check the stack using lua_gettop. In the case of luaL_error, see DM_LUA_ERROR.
Parameters
L (lua_State*) - lua statediff (int) - Number of expected items to be on the Lua stack once this struct goes out of scopeExamples
DM_LUA_STACK_CHECK(L, 1);
lua_pushnumber(L, 42);
Type: MACRO Diff is the expected difference of the stack size. If luaL_error, or another function that executes a long-jump, is part of the executed code, the stack guard cannot be guaranteed to execute at the end of the function. In that case you should manually check the stack using lua_gettop. In the case of luaL_error, see DM_LUA_ERROR.
Parameters
L (lua_State*) - lua statediff (int) - Number of expected items to be on the Lua stack once this struct goes out of scopeExamples
DM_LUA_STACK_CHECK(L, 1);
lua_pushnumber(L, 42);
Type: FUNCTION Gets the Lua context from a callback struct
Parameters
cbk (LuaCallbackInfo*) - Lua callback structReturns
L (lua_State*) - Lua stateType: FUNCTION Gets the Lua context from a callback struct
Parameters
cbk (LuaCallbackInfo*) - Lua callback structReturns
L (lua_State*) - Lua stateType: FUNCTION Retrieve current script instance from the global table and place it on the top of the stack, only valid when set. (see dmScript::GetMainThread)
Parameters
L (lua_State*) - lua stateType: FUNCTION Retrieve current script instance from the global table and place it on the top of the stack, only valid when set. (see dmScript::GetMainThread)
Parameters
L (lua_State*) - lua stateType: FUNCTION Retrieve Lua state from the context
Parameters
context (HContext) - the script contextReturns
state (lua_State*) - the lua stateType: FUNCTION Retrieve Lua state from the context
Parameters
context (HContext) - the script contextReturns
state (lua_State*) - the lua stateType: FUNCTION Retrieve the main thread lua state from any lua state (main thread or coroutine).
Parameters
L (lua_State*) - lua stateReturns
lua_State (lua_State*) - the main thread lua stateExamples
How to create a Lua callback
dmScript::LuaCallbackInfo* g_MyCallbackInfo = 0;
static void InvokeCallback(dmScript::LuaCallbackInfo* cbk)
{
if (!dmScript::IsCallbackValid(cbk))
return;
lua_State* L = dmScript::GetCallbackLuaContext(cbk);
DM_LUA_STACK_CHECK(L, 0)
if (!dmScript::SetupCallback(cbk))
{
dmLogError("Failed to setup callback");
return;
}
lua_pushstring(L, "Hello from extension!");
lua_pushnumber(L, 76);
dmScript::PCall(L, 3, 0); // instance + 2
dmScript::TeardownCallback(cbk);
}
static int Start(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
g_MyCallbackInfo = dmScript::CreateCallback(L, 1);
return 0;
}
static int Update(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
static int count = 0;
if( count++ == 5 )
{
InvokeCallback(g_MyCallbackInfo);
if (g_MyCallbackInfo)
dmScript::DestroyCallback(g_MyCallbackInfo);
g_MyCallbackInfo = 0;
}
return 0;
}
Type: FUNCTION Retrieve the main thread lua state from any lua state (main thread or coroutine).
Parameters
L (lua_State*) - lua stateReturns
lua_State (lua_State*) - the main thread lua stateExamples
How to create a Lua callback
dmScript::LuaCallbackInfo* g_MyCallbackInfo = 0;
static void InvokeCallback(dmScript::LuaCallbackInfo* cbk)
{
if (!dmScript::IsCallbackValid(cbk))
return;
lua_State* L = dmScript::GetCallbackLuaContext(cbk);
DM_LUA_STACK_CHECK(L, 0)
if (!dmScript::SetupCallback(cbk))
{
dmLogError("Failed to setup callback");
return;
}
lua_pushstring(L, "Hello from extension!");
lua_pushnumber(L, 76);
dmScript::PCall(L, 3, 0); // instance + 2
dmScript::TeardownCallback(cbk);
}
static int Start(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
g_MyCallbackInfo = dmScript::CreateCallback(L, 1);
return 0;
}
static int Update(lua_State* L)
{
DM_LUA_STACK_CHECK(L, 0);
static int count = 0;
if( count++ == 5 )
{
InvokeCallback(g_MyCallbackInfo);
if (g_MyCallbackInfo)
dmScript::DestroyCallback(g_MyCallbackInfo);
g_MyCallbackInfo = 0;
}
return 0;
}
Type: FUNCTION Gets as good as possible printable string from a hash or string
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valuebuffer (char*) - buffer receiving the valuebuffer_length (uint32_t) - the buffer lengthReturns
string (const char*) - Returns buffer. If buffer is non null, it will always contain a null terminated string. “Type: FUNCTION Gets as good as possible printable string from a hash or string
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valuebuffer (char*) - buffer receiving the valuebuffer_length (uint32_t) - the buffer lengthReturns
string (const char*) - Returns buffer. If buffer is non null, it will always contain a null terminated string. “Type: TYPEDEF The script context
Type: TYPEDEF The script context
Type: FUNCTION Check if Lua callback is valid.
Parameters
cbk (LuaCallbackInfo*) - Lua callback structType: FUNCTION Check if Lua callback is valid.
Parameters
cbk (LuaCallbackInfo*) - Lua callback structType: FUNCTION Check if the value at #index is a hash
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
result (bool) - true if the value at #index is a hashType: FUNCTION Check if the value at #index is a hash
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
result (bool) - true if the value at #index is a hashType: FUNCTION Check if the script instance in the lua state is valid. The instance is assumed to have been previously set by dmScript::SetInstance.
Parameters
L (lua_State*) - lua stateReturns
boolean (bool) - Returns true if the instance is validType: FUNCTION Check if the script instance in the lua state is valid. The instance is assumed to have been previously set by dmScript::SetInstance.
Parameters
L (lua_State*) - lua stateReturns
boolean (bool) - Returns true if the instance is validType: FUNCTION Check if the value at #index is a dmVMath::Matrix4*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
true (bool) - if value at #index is a dmVMath::Matrix4*Type: FUNCTION Check if the value at #index is a dmVMath::Matrix4*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
true (bool) - if value at #index is a dmVMath::Matrix4*Type: FUNCTION Check if the value at #index is a dmVMath::Quat*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
true (bool) - if value at #index is a dmVMath::Quat*Type: FUNCTION Check if the value at #index is a dmVMath::Quat*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
true (bool) - if value at #index is a dmVMath::Quat*Type: FUNCTION Check if the value at #index is a URL
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
result (bool) - true if the value at #index is a URLType: FUNCTION Check if the value at #index is a URL
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
result (bool) - true if the value at #index is a URLType: FUNCTION Check if the value at #index is a dmVMath::Vector3*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
true (bool) - if value at #index is a dmVMath::Vector3*Type: FUNCTION Check if the value at #index is a dmVMath::Vector3*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
true (bool) - if value at #index is a dmVMath::Vector3*Type: FUNCTION Check if the value at #index is a dmVMath::Vector4*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
true (bool) - if value at #index is a dmVMath::Vector4*Type: FUNCTION Check if the value at #index is a dmVMath::Vector4*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
true (bool) - if value at #index is a dmVMath::Vector4*Type: FUNCTION Convert a Json string to Lua table.
Notes
Parameters
L (lua_State*) - lua statejson (const char*) - json stringjson_len (size_t) - length of json stringReturns
int (int) - 1 if it succeeds. Throws a Lua error if it failsType: FUNCTION Convert a Json string to Lua table.
Notes
Parameters
L (lua_State*) - lua statejson (const char*) - json stringjson_len (size_t) - length of json stringReturns
int (int) - 1 if it succeeds. Throws a Lua error if it failsType: STRUCT callback info struct that will hold the relevant info needed to make a callback into Lua
Type: STRUCT callback info struct that will hold the relevant info needed to make a callback into Lua
Type: FUNCTION Convert a Lua table to a Json string
Parameters
L (lua_State*) - lua statejson (char*) - [out] Pointer to char, which will receive a newly allocated string. Use free().json_len (size_t*) - length of json stringReturns
int (int) - <0 if it fails. >=0 if it succeeds.Type: FUNCTION Convert a Lua table to a Json string
Parameters
L (lua_State*) - lua statejson (char*) - [out] Pointer to char, which will receive a newly allocated string. Use free().json_len (size_t*) - length of json stringReturns
int (int) - <0 if it fails. >=0 if it succeeds.Type: FUNCTION This function wraps lua_pcall with the addition of specifying an error handler which produces a backtrace. In the case of an error, the error is logged and popped from the stack.
Parameters
L (lua_State*) - lua statenargs (int) - number of argumentsnresult (int) - number of resultsReturns
error (int) - error code from pcallType: FUNCTION This function wraps lua_pcall with the addition of specifying an error handler which produces a backtrace. In the case of an error, the error is logged and popped from the stack.
Parameters
L (lua_State*) - lua statenargs (int) - number of argumentsnresult (int) - number of resultsReturns
error (int) - error code from pcallType: FUNCTION Push DDF message to Lua stack
Parameters
L (lua_State*) - the Lua statedescriptor (const dmDDF::Descriptor*) - field descriptordata (const char*) - the message data (i.e. the message struct)pointers_are_offsets (bool) - True if pointers are offsetsType: FUNCTION Push DDF message to Lua stack
Parameters
L (lua_State*) - the Lua statedescriptor (const dmDDF::Descriptor*) - field descriptordata (const char*) - the message data (i.e. the message struct)pointers_are_offsets (bool) - True if pointers are offsetsType: FUNCTION Push a hash value onto the supplied lua state, will increase the stack by 1.
Parameters
L (lua_State*) - Lua statehash (dmhash_t) - Hash value to pushType: FUNCTION Push a hash value onto the supplied lua state, will increase the stack by 1.
Parameters
L (lua_State*) - Lua statehash (dmhash_t) - Hash value to pushType: FUNCTION Push a matrix4 value onto the Lua stack. Will increase the stack by 1.
Parameters
L (lua_State*) - Lua statematrix (dmVMath::Matrix4) - dmVMath::Matrix4 value to pushType: FUNCTION Push a matrix4 value onto the Lua stack. Will increase the stack by 1.
Parameters
L (lua_State*) - Lua statematrix (dmVMath::Matrix4) - dmVMath::Matrix4 value to pushType: FUNCTION Push a quaternion value onto Lua stack. Will increase the stack by 1.
Parameters
L (lua_State*) - Lua statequat (dmVMath::Quat) - dmVMath::Quat value to pushType: FUNCTION Push a quaternion value onto Lua stack. Will increase the stack by 1.
Parameters
L (lua_State*) - Lua statequat (dmVMath::Quat) - dmVMath::Quat value to pushType: FUNCTION Push a URL value onto the supplied lua state, will increase the stack by 1.
Parameters
L (lua_State*) - Lua stateurl (dmMessage::URL&) - URL reference to pushType: FUNCTION Push a URL value onto the supplied lua state, will increase the stack by 1.
Parameters
L (lua_State*) - Lua stateurl (dmMessage::URL&) - URL reference to pushType: FUNCTION Push a dmVMath::Vector3 value onto the supplied lua state, will increase the stack by 1.
Parameters
L (lua_State*) - Lua statev (dmVMath::Vector3) - Vector3 value to pushType: FUNCTION Push a dmVMath::Vector3 value onto the supplied lua state, will increase the stack by 1.
Parameters
L (lua_State*) - Lua statev (dmVMath::Vector3) - Vector3 value to pushType: FUNCTION Push a dmVMath::Vector4 value onto the supplied lua state, will increase the stack by 1.
Parameters
L (lua_State*) - Lua statev (dmVMath::Vector4) - dmVMath::Vector4 value to pushType: FUNCTION Push a dmVMath::Vector4 value onto the supplied lua state, will increase the stack by 1.
Parameters
L (lua_State*) - Lua statev (dmVMath::Vector4) - dmVMath::Vector4 value to pushType: FUNCTION Creates and returns a reference, in the table at index t, for the object at the top of the stack (and pops the object). It also tracks number of global references kept.
Parameters
L (lua_State*) - lua statetable (int) - table the lua table that stores the references. E.g LUA_REGISTRYINDEXReturns
reference (int) - the new referenceType: FUNCTION Creates and returns a reference, in the table at index t, for the object at the top of the stack (and pops the object). It also tracks number of global references kept.
Parameters
L (lua_State*) - lua statetable (int) - table the lua table that stores the references. E.g LUA_REGISTRYINDEXReturns
reference (int) - the new referenceType: FUNCTION Creates a reference to the value at top of stack, the ref is done in the current instances context table. Expects SetInstance() to have been set with an value that has a meta table with META_GET_INSTANCE_CONTEXT_TABLE_REF method.
Parameters
L (lua_State*) - Lua stateReturns
lua (int) - ref to value or LUA_NOREF
Lua stack on entry
[-1] value
Lua stack on exitType: FUNCTION Resolves a url in string format into a dmMessage::URL struct. Special handling for:
Parameters
L (lua_State*) - Lua stateurl (const char*) - urlout_url (dmMessage::URL*) - where to store the resultdefault_url (dmMessage::URL*) - default urlReturns
result (dmMessage::Result) - dmMessage::RESULT_OK if the conversion succeededType: FUNCTION Creates a reference to the value at top of stack, the ref is done in the current instances context table. Expects SetInstance() to have been set with an value that has a meta table with META_GET_INSTANCE_CONTEXT_TABLE_REF method.
Parameters
L (lua_State*) - Lua stateReturns
lua (int) - ref to value or LUA_NOREF
Lua stack on entry
[-1] value
Lua stack on exitType: FUNCTION Resolves a url in string format into a dmMessage::URL struct. Special handling for:
Parameters
L (lua_State*) - Lua stateurl (const char*) - urlout_url (dmMessage::URL*) - where to store the resultdefault_url (dmMessage::URL*) - default urlReturns
result (dmMessage::Result) - dmMessage::RESULT_OK if the conversion succeededType: FUNCTION Resolves the value in the supplied index on the lua stack to a URL. It long jumps (calls luaL_error) on failure. It also gets the current (caller) url if the a pointer is passed to out_default_url
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueout_url (dmMessage::URL*) - where to store the resultout_default_url (dmMessage::URL*) - default URL used in the resolve, can be 0x0 (not used)Returns
result (int) - 0 if successful. Throws Lua error on failureType: FUNCTION Resolves the value in the supplied index on the lua stack to a URL. It long jumps (calls luaL_error) on failure. It also gets the current (caller) url if the a pointer is passed to out_default_url
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueout_url (dmMessage::URL*) - where to store the resultout_default_url (dmMessage::URL*) - default URL used in the resolve, can be 0x0 (not used)Returns
result (int) - 0 if successful. Throws Lua error on failureType: FUNCTION Sets the current script instance Set the value on the top of the stack as the instance into the global table and pops it from the stack. (see dmScript::GetMainThread)
Parameters
L (lua_State*) - lua stateType: FUNCTION Sets the current script instance Set the value on the top of the stack as the instance into the global table and pops it from the stack. (see dmScript::GetMainThread)
Parameters
L (lua_State*) - lua stateType: FUNCTION The Lua stack after a successful call:
[-4] old instance
[-3] context table
[-2] callback
[-1] self
In the event of an unsuccessful call, the Lua stack is unchanged
Parameters
cbk (LuaCallbackInfo*) - Lua callback structReturns
true (bool) - if the setup was successfulType: FUNCTION The Lua stack after a successful call:
[-4] old instance
[-3] context table
[-2] callback
[-1] self
In the event of an unsuccessful call, the Lua stack is unchanged
Parameters
cbk (LuaCallbackInfo*) - Lua callback structReturns
true (bool) - if the setup was successfulType: FUNCTION Sets the previous instance Expects Lua stack:
[-2] old instance
[-1] context table
Both values are removed from the stack
Parameters
cbk (LuaCallbackInfo*) - Lua callback structType: FUNCTION Sets the previous instance Expects Lua stack:
[-2] old instance
[-1] context table
Both values are removed from the stack
Parameters
cbk (LuaCallbackInfo*) - Lua callback structType: FUNCTION Check if the value at #index is a hash
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
hash (dmhash_t*) - pointer to hash or 0 if it’s not a hashType: FUNCTION Check if the value at #index is a hash
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
hash (dmhash_t*) - pointer to hash or 0 if it’s not a hashType: FUNCTION Get the value at index as a dmVMath::Matrix4*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
quat (dmVMath::Matrix4*) - The pointer to the value, or 0 if not correct typeType: FUNCTION Get the value at index as a dmVMath::Matrix4*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
quat (dmVMath::Matrix4*) - The pointer to the value, or 0 if not correct typeType: FUNCTION Get the value at index as a dmVMath::Quat*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
quat (dmVMath::Quat*) - The pointer to the value, or 0 if not correct typeType: FUNCTION Get the value at index as a dmVMath::Quat*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
quat (dmVMath::Quat*) - The pointer to the value, or 0 if not correct typeType: FUNCTION get the value at index as a dmMessage::URL*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
hash (dmhash_t*) - pointer to URL or 0 if it’s not a URLType: FUNCTION get the value at index as a dmMessage::URL*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
hash (dmhash_t*) - pointer to URL or 0 if it’s not a URLType: FUNCTION Get the value at index as a dmVMath::Vector3*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
v (dmVMath::Vector3*) - The pointer to the value, or 0 if not correct typeType: FUNCTION Get the value at index as a dmVMath::Vector3*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
v (dmVMath::Vector3*) - The pointer to the value, or 0 if not correct typeType: FUNCTION Get the value at index as a dmVMath::Vector4*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
v (dmVMath::Vector4*) - The pointer to the value, or 0 if not correct typeType: FUNCTION Get the value at index as a dmVMath::Vector4*
Parameters
L (lua_State*) - Lua stateindex (int) - Index of the valueReturns
v (dmVMath::Vector4*) - The pointer to the value, or 0 if not correct typeType: FUNCTION Releases reference ref from the table at index t (see luaL_ref). The entry is removed from the table, so that the referred object can be collected. It also decreases the number of global references kept
Parameters
L (lua_State*) - lua statetable (int) - table the lua table that stores the references. E.g LUA_REGISTRYINDEXreference (int) - the reference to the objectType: FUNCTION Releases reference ref from the table at index t (see luaL_ref). The entry is removed from the table, so that the referred object can be collected. It also decreases the number of global references kept
Parameters
L (lua_State*) - lua statetable (int) - table the lua table that stores the references. E.g LUA_REGISTRYINDEXreference (int) - the reference to the objectType: FUNCTION Deletes the instance local lua reference Expects SetInstance() to have been set with an value that has a meta table with META_GET_INSTANCE_CONTEXT_TABLE_REF method.
Parameters
L (lua_State*) - Lua stateref (int) - ref to value or LUA_NOREF
Lua stack on entry
Lua stack on exitType: FUNCTION Deletes the instance local lua reference Expects SetInstance() to have been set with an value that has a meta table with META_GET_INSTANCE_CONTEXT_TABLE_REF method.
Parameters
L (lua_State*) - Lua stateref (int) - ref to value or LUA_NOREF
Lua stack on entry
Lua stack on exitType: FUNCTION Converts a URL into a readable string. Useful for e.g. error messages
Parameters
url (dmMessage::URL*) - urlbuffer (char*) - the output bufferbuffer_size (uint32_t) - the output buffer sizeReturns
buffer (const char*) - returns the passed in bufferType: FUNCTION Converts a URL into a readable string. Useful for e.g. error messages
Parameters
url (dmMessage::URL*) - urlbuffer (char*) - the output bufferbuffer_size (uint32_t) - the output buffer sizeReturns
buffer (const char*) - returns the passed in buffer