Beispiel #1
0
		public void SetTableStringField2 ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a={b={c=\"test\"}}");
				LuaTable tab = lua.GetTable ("a");
				tab ["b.c"] = "new test";
				string str = lua.GetString ("a.b.c");
				//Console.WriteLine("a.b.c="+str);
				Assert.AreEqual (str, "new test");
			}
		}
Beispiel #2
0
		public void SetStringInTable ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a={b={c=\"test\"}}");
				lua ["a.b.c"] = "new test";
				string str = lua.GetString ("a.b.c");
				//Console.WriteLine("a.b.c="+str);
				Assert.AreEqual (str, "new test");
			}
		}
Beispiel #3
0
		public void SetGlobalString ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a=\"test\"");
				lua ["a"] = "new test";
				string str = lua.GetString ("a");
				//Console.WriteLine("a="+str);
				Assert.AreEqual (str, "new test");
			}
		}
Beispiel #4
0
		public void TestMultipleOutParameters ()
		{
			using (Lua lua = new Lua ()) {
				TestClass t1 = new TestClass ();
				lua ["netobj"] = t1;
				lua.DoString ("a,b,c=netobj:outValMutiple(2)");
				int a = (int)lua.GetNumber ("a");
				string b = (string)lua.GetString ("b");
				string c = (string)lua.GetString ("c");
				Assert.AreEqual (2, a);
				Assert.AreNotEqual (null, b);
				Assert.AreNotEqual (null, c);
			}
		}
Beispiel #5
0
		public void ReadArrayField ()
		{
			using (Lua lua = new Lua ()) {
				string[] arr = new string [] { "str1", "str2", "str3" };
				lua ["netobj"] = arr;
				lua.DoString ("val=netobj[1]");
				string val = lua.GetString ("val");
				Assert.AreEqual ("str2", val);
				//Console.WriteLine("new val(from array to Lua)="+val);
			}
		}
Beispiel #6
0
		public void TestConstructorOverload ()
		{
			using (var l = new Lua ()) {
				l.LoadCLRPackage ();
				l.DoString (" import ('NLuaTest','NLuaTest.Mock') ");
				l.DoString (@"					
					e1 = Entity()
					e2 = Entity ('str_param')
					e3 = Entity (10)
					p1 = e1.Property
					p2 = e2.Property
					p3 = e3.Property
				");
				string p1 = l.GetString ("p1");
				string p2 = l.GetString ("p2");
				string p3 = l.GetString ("p3");
				Assert.AreEqual ("Default", p1, "#1");
				Assert.AreEqual ("String", p2, "#1");
				Assert.AreEqual ("Int", p3, "#1");
			}
		}