当前位置: 首页>>代码示例>>C#>>正文


C# Lua.GetNumber方法代码示例

本文整理汇总了C#中NLua.Lua.GetNumber方法的典型用法代码示例。如果您正苦于以下问题:C# Lua.GetNumber方法的具体用法?C# Lua.GetNumber怎么用?C# Lua.GetNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NLua.Lua的用法示例。


在下文中一共展示了Lua.GetNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LuaDelegateValueTypesByRefParam

		public void LuaDelegateValueTypesByRefParam ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("luanet.load_assembly('NLuaTest')");
				lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
				lua.DoString ("test=TestClass()");
				lua.DoString ("function func(x,y) return x+y; end");
				lua.DoString ("test=TestClass()");
				lua.DoString ("a=test:callDelegate3(func)");
				int a = (int)lua.GetNumber ("a");
				Assert.AreEqual (5, a);
				//Console.WriteLine("delegate returned: "+a);
			}
		}
开发者ID:zhangf911,项目名称:NLua,代码行数:14,代码来源:AAACodeGenTests.cs

示例2: TestMultipleOutParameters

		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);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:14,代码来源:LuaTests.cs

示例3: LuaTableInheritedMethod

		public void LuaTableInheritedMethod ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("luanet.load_assembly('NLuaTest')");
				lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
				lua.DoString ("test={}");
				lua.DoString ("function test:overridableMethod(x,y) return x*y; end");
				lua.DoString ("luanet.make_object(test,'NLuaTest.Mock.TestClass')");
				lua.DoString ("test:setVal(3)");
				lua.DoString ("a=test.testval");
				int a = (int)lua.GetNumber ("a");
				lua.DoString ("luanet.free_object(test)");
				Assert.AreEqual (3, a);
				//Console.WriteLine("interface returned: "+a);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:16,代码来源:LuaTests.cs

示例4: LuaTableOverridedMethod

		public void LuaTableOverridedMethod ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("luanet.load_assembly('NLuaTest')");
				lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
				lua.DoString ("test={}");
				lua.DoString ("function test:overridableMethod(x,y) return x*y; end");
				lua.DoString ("luanet.make_object(test,'NLuaTest.Mock.TestClass')");
				lua.DoString ("a=TestClass.callOverridable(test,2,3)");
				int a = (int)lua.GetNumber ("a");
				lua.DoString ("luanet.free_object(test)");
				Assert.AreEqual (6, a);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:14,代码来源:LuaTests.cs

示例5: TestCoroutine

		public void TestCoroutine ()
		{
			using (Lua lua = new Lua ()) {
				lua.LoadCLRPackage ();
				lua.RegisterFunction ("func1", null, typeof (TestClass2).GetMethod ("func"));
				lua.DoString ("function yielder() " +
								"a=1;" + "coroutine.yield();" +
								"func1(3,2);" + "coroutine.yield();" + // This line triggers System.NullReferenceException
								"a=2;" + "coroutine.yield();" +
							 "end;" +
							 "co_routine = coroutine.create(yielder);" +
							 "while coroutine.resume(co_routine) do end;");

				double num = lua.GetNumber ("a");
				//Console.WriteLine("a="+num);
				Assert.AreEqual (num, 2d);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:18,代码来源:LuaTests.cs

示例6: TestCallMethodWithParams2

		public void TestCallMethodWithParams2 ()
		{
			using (var l = new Lua ()) {
				l.LoadCLRPackage ();
				l.DoString (" import ('NLuaTest','NLuaTest.Mock') ");
				l.DoString (@"					
					r = TestClass.MethodWithParams(2)			
				");
				int r =  (int)l.GetNumber ("r");
				Assert.AreEqual (0, r, "#1");
			}
		}
开发者ID:zhangf911,项目名称:NLua,代码行数:12,代码来源:LuaTests.cs

示例7: CallGlobalFunctionOneArg

		public void CallGlobalFunctionOneArg ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a=2\nfunction f(x)\na=a+x\nend");
				lua.GetFunction ("f").Call (1);
				double num = lua.GetNumber ("a");
				//Console.WriteLine("a="+num);
				Assert.AreEqual (num, 3d);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:10,代码来源:LuaTests.cs

示例8: GetAndSetTable

		public void GetAndSetTable ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a={b={c=2}}\nb={c=3}");
				LuaTable tab = lua.GetTable ("b");
				lua ["a.b"] = tab;
				double num = lua.GetNumber ("a.b.c");
				//Console.WriteLine("a.b.c="+num);
				Assert.AreEqual (num, 3d);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:11,代码来源:LuaTests.cs

示例9: NLuaValueTypesOutParam

		public void NLuaValueTypesOutParam ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("luanet.load_assembly('NLuaTest')");
				lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
				lua.DoString ("test=TestClass()");
				lua.DoString ("itest={}");
				lua.DoString ("function itest:test2(x) return x,x*2; end");
				lua.DoString ("test=TestClass()");
				lua.DoString ("a=test:callInterface2(itest)");
				int a = (int)lua.GetNumber ("a");
				Assert.AreEqual (6, a);
				//Console.WriteLine("interface returned: "+a);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:15,代码来源:LuaTests.cs

示例10: NLuaAAValueTypes

		public void NLuaAAValueTypes ()
		{
			using (Lua lua = new Lua ()) {
				lua.RegisterLuaClassType (typeof(ITest), typeof(LuaITestClassHandler));
				lua.DoString ("luanet.load_assembly('NLuaTest')");
				lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
				lua.DoString ("test=TestClass()");
				lua.DoString ("itest={}");
				lua.DoString ("function itest:test1(x,y) return x+y; end");
				lua.DoString ("test=TestClass()");
				lua.DoString ("a=test:callInterface1(itest)");
				int a = (int)lua.GetNumber ("a");
				Assert.AreEqual (5, a);
				//Console.WriteLine("interface returned: "+a);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:16,代码来源:LuaTests.cs

示例11: LuaDelegateReferenceTypesByRefParam

		public void LuaDelegateReferenceTypesByRefParam ()
		{
			using (Lua lua = new Lua ()) {
				lua.RegisterLuaDelegateType (typeof(TestDelegate7), typeof(LuaTestDelegate7Handler));
				lua.DoString ("luanet.load_assembly('NLuaTest')");
				lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
				lua.DoString ("test=TestClass()");
				lua.DoString ("function func(x,y) return TestClass(x+y.testval); end");
				lua.DoString ("a=test:callDelegate7(func)");
				int a = (int)lua.GetNumber ("a");
				Assert.AreEqual (5, a);
				//Console.WriteLine("delegate returned: "+a);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:14,代码来源:LuaTests.cs

示例12: LuaDelegateValueTypesOutParam

		public void LuaDelegateValueTypesOutParam ()
		{
			using (Lua lua = new Lua ()) {
				lua.RegisterLuaDelegateType (typeof(TestDelegate2), typeof(LuaTestDelegate2Handler));
				lua.DoString ("luanet.load_assembly('NLuaTest')");
				lua.DoString ("TestClass=luanet.import_type('NLuaTest.Mock.TestClass')");
				lua.DoString ("test=TestClass()");
				lua.DoString ("function func(x) return x,x*2; end");
				lua.DoString ("test=TestClass()");
				lua.DoString ("a=test:callDelegate2(func)");
				int a = (int)lua.GetNumber ("a");
				Assert.AreEqual (6, a);
				//Console.WriteLine("delegate returned: "+a);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:15,代码来源:LuaTests.cs

示例13: CallObjectMethodDistinctInterfaces

		public void CallObjectMethodDistinctInterfaces ()
		{
			using (Lua lua = new Lua ()) {
				TestClass t1 = new TestClass ();
				lua ["netobj"] = t1;
				lua.DoString ("a=netobj:foo()");
				lua.DoString ("b=netobj['NLuaTest.Mock.IFoo1.foo']");
				int a = (int)lua.GetNumber ("a");
				int b = (int)lua.GetNumber ("b");
				Assert.AreEqual (5, a);
				Assert.AreEqual (1, b);
				//Console.WriteLine("function returned (from lua)="+a+","+b);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:14,代码来源:LuaTests.cs

示例14: CallObjectMethodByRefParam

		public void CallObjectMethodByRefParam ()
		{
			using (Lua lua = new Lua ()) {
				TestClass t1 = new TestClass ();
				lua ["netobj"] = t1;
				lua.DoString ("a,b=netobj:outVal(2,3)");
				int a = (int)lua.GetNumber ("a");
				int b = (int)lua.GetNumber ("b");
				Assert.AreEqual (2, a);
				Assert.AreEqual (5, b);
				//Console.WriteLine("function returned (from lua)="+a+","+b);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:13,代码来源:LuaTests.cs

示例15: CallObjectMethod

		public void CallObjectMethod ()
		{
			using (Lua lua = new Lua ()) {
				TestClass t1 = new TestClass ();
				t1.testval = 4;
				lua ["netobj"] = t1;
				lua.DoString ("netobj:setVal(3)");
				Assert.AreEqual (3, t1.testval);
				//Console.WriteLine("new val(from C#)="+t1.testval);
				lua.DoString ("val=netobj:getVal()");
				int val = (int)lua.GetNumber ("val");
				Assert.AreEqual (3, val);
				//Console.WriteLine("new val(from Lua)="+val);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:15,代码来源:LuaTests.cs


注:本文中的NLua.Lua.GetNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。