mirror of
https://github.com/tym1116/BH3.git
synced 2025-12-18 01:14:59 +01:00
41 lines
756 B
C#
41 lines
756 B
C#
using System;
|
|
|
|
namespace LuaInterface
|
|
{
|
|
public class LuaClassHelper
|
|
{
|
|
public static LuaFunction getTableFunction(LuaTable luaTable, string name)
|
|
{
|
|
object obj = luaTable.rawget(name);
|
|
if (obj is LuaFunction)
|
|
{
|
|
return (LuaFunction)obj;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static object callFunction(LuaFunction function, object[] args, Type[] returnTypes, object[] inArgs, int[] outArgs)
|
|
{
|
|
object[] array = function.call(inArgs, returnTypes);
|
|
object result;
|
|
int num;
|
|
if (returnTypes[0] == typeof(void))
|
|
{
|
|
result = null;
|
|
num = 0;
|
|
}
|
|
else
|
|
{
|
|
result = array[0];
|
|
num = 1;
|
|
}
|
|
for (int i = 0; i < outArgs.Length; i++)
|
|
{
|
|
args[outArgs[i]] = array[num];
|
|
num++;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|