public static LuaTable CallFunction(this LuaState lua, int index, params object[] parameters) { lua.RawGetI(LuaDef.LUA_REGISTRYINDEX, index); lua.PushParameters(parameters); var status = lua.PCall(parameters.Length, 1, 0); // call if (status != ThreadStatus.LUA_OK) { Debug.LogError($"{lua.ToString(-1)}, status - {status}"); } var ret = LuaTable.Clone(lua.Last().V.HValue()); lua.Pop(1); return(ret); }
public static LuaTable CallFunction(this LuaState lua, LuaTable table, string name, object[] parameters) { lua.PushFunctionFromTable(table, name); lua.PushTable(table); // self lua.PushParameters(parameters); // parameters var status = lua.PCall(parameters.Length + 1, 1, 0); // call if (status != ThreadStatus.LUA_OK) { Debug.LogError($"{lua.ToString(-1)}, status - {status}"); } var ret = LuaTable.Clone(lua.Last().V.HValue()); lua.Pop(1); table.UpdateAllGoInTable(); return(ret); }