What I'm trying to do:
someTable={
function Add(a,b)
return a+b
end
function Mult(a,b)
return a*b
end
function CallFunc(name,inputs)
funcByName(table.unpack(inputs))
end
}
And then I can call it from C#:
void Call(string name, params object[] inputs)
And the question is, how do I call a function by string name?
Also, CallFunc will be in metatable.
If there is any other way of solving the issue I'd also like to hear.
(Sorry for the formating but I'm writing from a phone for some reason)
Edit: T'was foolish of me to ask the question. What I was trying to to is to access a "member function" by its name. That is not really how lua works. So the answer is simply:
function CallFunc(self, name, ...)
self[name](...)
end
And in C#:
void CallLuaFunc(LuaTable tb,string name,params object[] inputs){
//call lua from c#
}
Thus the main c# program only needs to be compiled once since it can call any lua function by its name.
(BTW the library is XLua, a lua library for Unity3D to enable hotfix)