lua_call

lua_call calls a Lua function.

ret = lua_call(function, par1, ...)
<r1, r2, ...> = lua_call(function, par1, ...)

Return Value

ret is a number (64 bit double) or a Lua value.

LUA_TNIL
LUA_TBOOLEAN
LUA_TLIGHTUSERDATA
LUA_TSTRING
LUA_TTABLE
LUA_TFUNCTION
LUA_TUSERDATA
LUA_TTHREAD

Parameters

function

function

par1

par1

...

Example

Invoke sin function from the Lua math library:

lmath = lua_require("math")
lsin = lua_get(lmath, "sin")

lua_call(lsin, 1)
    0.8415

The lua_require and lua_get function uses lua_call.

def lua_require(s)
{
    return lua_call("require", s)
}

def lua_get(table, index)
{
    return lua_call("rawget", table, index);
}

Beispiel

sin-Funktion der Lua-math-Library aufrufen:

lmath = lua_require("math")
lsin = lua_get(lmath, "sin")

lua_call(lsin, 1)
    0.8415

Die lua_require und lua_get-Funktionen verwenden auch die lua_call-Funktion.

def lua_require(s)
{
    return lua_call("require", s)
}

def lua_get(table, index)
{
    return lua_call("rawget", table, index);
}

History

Version Description
R2016.0 New.

id-1323776