How to pass a table to lua with c#
I'm using the LuaInterface,this is my c# code
using System;
using System.IO;
using System.Text;
using LuaInterface;
namespace GetLuaTable
{
class Program
{
static void Main(string[] args)
{
Lua netLua = new Lua();
CShaprFunction cShapr = new CShaprFunction();
netLua.RegisterFunction("CShaprConsoleLine", cShapr, cShapr.GetType().GetMethod("CShaprConsoleLine"));
netLua.RegisterFunction("CSharpGetTableFromStr", cShapr, cShapr.GetType().GetMethod("CSharpGetTableFromStr"));
netLua.DoFile("MyLua.lua");
netLua.GetFunction("main").Call();
Console.ReadKey();
}
}
class CShaprFunction
{
public void CShaprConsoleLine(object obj)
{
Console.WriteLine(obj);
}
public LuaTable CSharpGetTableFromStr(string name)
{
Lua lua = new Lua();
lua.DoString("a={\"test\"}");
LuaTable tab = lua.GetTable(name);
return tab;
}
}
}
this is lua code:
function main()
CShaprConsoleLine("Start")
local tmptable = CSharpGetTableFromStr("a")
CShaprConsoleLine(type(tmptable))
CShaprConsoleLine("end")
end
But I get the result,the tmptable is function type not table type. like this:
Start
function
end
so how can I pass a table to lua?