Reputation: 415
How do you register Lua method info (of static public void) to a context in AluminiumLua?
Upvotes: 2
Views: 678
Reputation: 21
You can achieve this by providing a delegate matching your method's signature.
using System;
using AluminumLua;
public delegate void HelloDelegate();
class Program
{
public static void Hello()
{
Console.Write("Hello world!");
}
static void Main()
{
var context = new LuaContext();
var obj = LuaObject.FromDelegate(new HelloDelegate(Hello));
context.SetGlobal("hello", obj);
context.Get("hello").AsFunction().Invoke(new LuaObject[] { });
}
}
Upvotes: 2