コード例 #1
0
ファイル: LuaTableTests.cs プロジェクト: chenzuo/NetLua
        public static void SecondTableTest()
        {
            NetLua.Lua lua = new NetLua.Lua();
            lua.DoString(
@" a={}
a['x'] = 10        
b = a");
            LuaObject obj1 = 10;
            LuaObject obj2 = lua.DoString("return b['x']")[0];
            Assert.IsTrue(obj1.Equals(obj2));

            lua.DoString("b['x'] = 20");
            obj1 = 20;
            obj2 = lua.DoString("return a['x']")[0];
            Assert.IsTrue(obj1.Equals(obj2));
        }
コード例 #2
0
ファイル: LuaTableTests.cs プロジェクト: chenzuo/NetLua
        public static void FirstTableTest()
        {
            NetLua.Lua lua = new NetLua.Lua();
            lua.DoString(
@" a={}
k = 'x'
a[k] = 10        
a[20] = 'great'");
            LuaObject obj1 = 10;
            LuaObject obj2 = lua.DoString("return a['x']")[0];
            Assert.IsTrue(obj1.Equals(obj2));

            lua.DoString("k = 20");
            obj1 = "great";
            obj2 = lua.DoString("return a[k]")[0];
            Assert.IsTrue(obj1.Equals(obj2));
        }
コード例 #3
0
        public static void SecondTableTest()
        {
            NetLua.Lua lua = new NetLua.Lua();
            lua.DoString(
                @" a={}
a['x'] = 10        
b = a");
            LuaObject obj1 = 10;
            LuaObject obj2 = lua.DoString("return b['x']")[0];

            Assert.IsTrue(obj1.Equals(obj2));

            lua.DoString("b['x'] = 20");
            obj1 = 20;
            obj2 = lua.DoString("return a['x']")[0];
            Assert.IsTrue(obj1.Equals(obj2));
        }
コード例 #4
0
        public static void FirstTableTest()
        {
            NetLua.Lua lua = new NetLua.Lua();
            lua.DoString(
                @" a={}
k = 'x'
a[k] = 10        
a[20] = 'great'");
            LuaObject obj1 = 10;
            LuaObject obj2 = lua.DoString("return a['x']")[0];

            Assert.IsTrue(obj1.Equals(obj2));

            lua.DoString("k = 20");
            obj1 = "great";
            obj2 = lua.DoString("return a[k]")[0];
            Assert.IsTrue(obj1.Equals(obj2));
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: chenzuo/NetLua
        static void Main(string[] args)
        {
            Lua lua = new Lua();
            lua.DynamicContext.print = (LuaFunction)print;
            lua.DynamicContext.read = (LuaFunction)read;

            MathLibrary.AddMathLibrary(lua.Context);
            IoLibrary.AddIoLibrary(lua.Context);

            lua.DoFile("life.lua");

            while (true)
            {
                lua.DoString(Console.ReadLine());
            }
        }