using NLua; using System; public class Program { public static void Main() { Lua lua = new Lua(); lua.DoString("print(\"Hello, World!\")"); Console.ReadLine(); } }
using NLua; using System; public class Program { public static void Main() { Lua lua = new Lua(); lua.DoString("myVar = 10"); int myVar = lua.GetThis code creates a new instance of Lua and sets a variable named "myVar" to 10. It then retrieves the value of "myVar" as an integer using the Get method. The code then sets "myVar" to a string and retrieves the value of "myVar" as a string using the Get method. Package library: NLua.("myVar"); Console.WriteLine(myVar); // prints 10 lua.DoString("myVar = \"Hello, World!\""); string myStringVar = lua.Get ("myVar"); Console.WriteLine(myStringVar); // prints "Hello, World!" Console.ReadLine(); } }