using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NLua;
using Nlua2;
namespace Nlua2
{
public class Test
{
public Test()
{
Console.WriteLine("IT WORKED");
}
static public void Method()
{
Console.WriteLine("IT WORKED2");
}
}
}
namespace Nlua
{
class Program
{
static void Main(string[] args)
{
Lua state = new Lua();
Test obj = new Test();
state["obj"] = obj; // Create a global value 'obj' of .NET type SomeClass
// This could be any .NET object, from BCL or from your assemblies
state.LoadCLRPackage();
try
{
state.DoString(@"
import ('Nlua', 'Nlua2')
local obj2 = Test()
obj.Method()
");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
}
}
local obj2 = Test() выдает
[string "chunk"]:3: attempt to call global 'Test' (a nil value)
Test
. Вы ж ему толькоobj
скормили. Думаю, вам нужно убрать строчкуlocal obj2 = Test()
из скрипта.