MCPcopy Create free account
hub / github.com/cuberite/cuberite / CallFunctionFromForeignState

Method CallFunctionFromForeignState

src/Bindings/PluginLua.cpp:1585–1613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1583
1584
1585int cPluginLua::CallFunctionFromForeignState(
1586 const AString & a_FunctionName,
1587 cLuaState & a_ForeignState,
1588 int a_ParamStart,
1589 int a_ParamEnd
1590)
1591{
1592 cCSLock Lock(m_CriticalSection);
1593
1594 // Call the function:
1595 int NumReturns = m_LuaState.CallFunctionWithForeignParams(a_FunctionName, a_ForeignState, a_ParamStart, a_ParamEnd);
1596 if (NumReturns < 0)
1597 {
1598 // The call has failed, an error has already been output to the log, so just silently bail out with the same error
1599 return NumReturns;
1600 }
1601
1602 // Copy all the return values:
1603 int Top = lua_gettop(m_LuaState);
1604 int res = a_ForeignState.CopyStackFrom(m_LuaState, Top - NumReturns + 1, Top);
1605
1606 // Remove the return values off this stack:
1607 if (NumReturns > 0)
1608 {
1609 lua_pop(m_LuaState, NumReturns);
1610 }
1611
1612 return res;
1613}
1614
1615
1616

Callers 2

ItemMethod · 0.80
tolua_cPlugin_CallFunction · 0.80

Calls 3

lua_gettopFunction · 0.85
CopyStackFromMethod · 0.80

Tested by

no test coverage detected