Exposing functions to LUA

Following the previous thread. Here is an example how to expose a C# function to the LUA script:

private readonly Lua lua = new Lua();

static void Main(string[] args)
{
 lua.RegisterFunction("talk", this, GetType().GetMethod("Talk"));
 lua.DoFile("script.lua");
}

public void Talk(string s)
{
 Console.WriteLine(s);
}

And the script.lua file:
talk("Hello World")

0 kommentarer:

Post a Comment