本文整理汇总了C#中Lua.GetNumber方法的典型用法代码示例。如果您正苦于以下问题:C# Lua.GetNumber方法的具体用法?C# Lua.GetNumber怎么用?C# Lua.GetNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lua
的用法示例。
在下文中一共展示了Lua.GetNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallGlobalFunctionNoArgs
public void CallGlobalFunctionNoArgs()
{
using (Lua lua = new Lua())
{
lua.DoString("a=2\nfunction f()\na=3\nend");
lua.GetFunction("f").Call();
double num = lua.GetNumber("a");
//Console.WriteLine("a="+num);
Assert.Equal(num, 3d);
}
}
示例2: LuaTableInheritedMethod
public void LuaTableInheritedMethod()
{
using (Lua lua = new Lua())
{
lua.DoString("luanet.load_assembly('LuaInterface.Test')");
lua.DoString("TestClass=luanet.import_type('LuaInterface.Test.Mock.TestClass')");
lua.DoString("test={}");
lua.DoString("function test:overridableMethod(x,y) return x*y; end");
lua.DoString("luanet.make_object(test,'LuaInterface.Test.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.Equal(3, a);
//Console.WriteLine("interface returned: "+a);
}
}
示例3: LuaTableBaseMethod
public void LuaTableBaseMethod()
{
using (Lua lua = new Lua())
{
lua.DoString("luanet.load_assembly('LuaInterface.Test')");
lua.DoString("TestClass=luanet.import_type('LuaInterface.Test.Mock.TestClass')");
lua.DoString("test={}");
lua.DoString("function test:overridableMethod(x,y) return 2*self.base:overridableMethod(x,y); end");
lua.DoString("luanet.make_object(test,'LuaInterface.Test.Mock.TestClass')");
lua.DoString("a=TestClass:callOverridable(test,2,3)");
int a = (int)lua.GetNumber("a");
lua.DoString("luanet.free_object(test)");
Assert.Equal(10, a);
//Console.WriteLine("interface returned: "+a);
}
}
示例4: LuaInterfaceValueTypesReturnReferenceType
public void LuaInterfaceValueTypesReturnReferenceType()
{
using (Lua lua = new Lua())
{
lua.DoString("luanet.load_assembly('LuaInterface.Test')");
lua.DoString("TestClass=luanet.import_type('LuaInterface.Test.Mock.TestClass')");
lua.DoString("test=TestClass()");
lua.DoString("itest={}");
lua.DoString("function itest:test4(x,y) return TestClass(x+y); end");
lua.DoString("test=TestClass()");
lua.DoString("a=test:callInterface4(itest)");
int a = (int)lua.GetNumber("a");
Assert.Equal(5, a);
//Console.WriteLine("interface returned: "+a);
}
}
示例5: LuaInterfaceValueTypesOutParam
public void LuaInterfaceValueTypesOutParam()
{
using (Lua lua = new Lua())
{
lua.DoString("luanet.load_assembly('LuaInterface.Test')");
lua.DoString("TestClass=luanet.import_type('LuaInterface.Test.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.Equal(6, a);
//Console.WriteLine("interface returned: "+a);
}
}
示例6: LuaInterfaceValueProperty
public void LuaInterfaceValueProperty()
{
using (Lua lua = new Lua())
{
lua.DoString("luanet.load_assembly('LuaInterface.Test')");
lua.DoString("TestClass=luanet.import_type('LuaInterface.Test.Mock.TestClass')");
lua.DoString("test=TestClass()");
lua.DoString("itest={}");
lua.DoString("function itest:get_intProp() return itest.int_prop; end");
lua.DoString("function itest:set_intProp(val) itest.int_prop=val; end");
lua.DoString("a=test:callInterface8(itest)");
int a = (int)lua.GetNumber("a");
Assert.Equal(3, a);
//Console.WriteLine("interface returned: "+a);
}
}
示例7: LuaDelegateValueTypesByRefParam
public void LuaDelegateValueTypesByRefParam()
{
using (Lua lua = new Lua())
{
lua.DoString("luanet.load_assembly('LuaInterface.Test')");
lua.DoString("TestClass=luanet.import_type('LuaInterface.Test.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.Equal(5, a);
//Console.WriteLine("delegate returned: "+a);
}
}
示例8: 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.Equal(2, a);
Assert.NotNull(b);
Assert.NotNull(c);
}
}
示例9: GetNumberInTable
public void GetNumberInTable()
{
using (Lua lua = new Lua())
{
lua.DoString("a={b={c=2}}");
double num = lua.GetNumber("a.b.c");
//Console.WriteLine("a.b.c="+num);
Assert.Equal(num, 2d);
}
}
示例10: GetGlobalNumber
public void GetGlobalNumber()
{
using (Lua lua = new Lua())
{
lua.DoString("a=2");
double num = lua.GetNumber("a");
//Console.WriteLine("a="+num);
Assert.Equal(num, 2d);
}
}
示例11: 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.Equal(num, 3d);
}
}
示例12: CallObjectMethodOverloadedOutParam
public void CallObjectMethodOverloadedOutParam()
{
using (Lua lua = new Lua())
{
TestClass t1 = new TestClass();
lua["netobj"] = t1;
lua.DoString("a,b=netobj:outVal(2)");
int a = (int)lua.GetNumber("a");
int b = (int)lua.GetNumber("b");
Assert.Equal(2, a);
Assert.Equal(5, b);
//Console.WriteLine("function returned (from lua)="+a+","+b);
}
}
示例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['LuaInterface.Test.Mock.IFoo1.foo'](netobj)");
int a = (int)lua.GetNumber("a");
int b = (int)lua.GetNumber("b");
Assert.Equal(5, a);
Assert.Equal(3, b);
//Console.WriteLine("function returned (from lua)="+a+","+b);
}
}
示例14: 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.Equal(3, t1.testval);
//Console.WriteLine("new val(from C#)="+t1.testval);
lua.DoString("val=netobj:getVal()");
int val = (int)lua.GetNumber("val");
Assert.Equal(3, val);
//Console.WriteLine("new val(from Lua)="+val);
}
}
示例15: LuaTableOverridedMethod
public void LuaTableOverridedMethod()
{
using (Lua lua = new Lua())
{
lua.DoString("luanet.load_assembly('LuaInterface.Test')");
lua.DoString("TestClass=luanet.import_type('LuaInterface.Test.Mock.TestClass')");
lua.DoString("test={}");
lua.DoString("function test:overridableMethod(x,y) return x*y; end");
lua.DoString("luanet.make_object(test,'LuaInterface.Test.Mock.TestClass')");
lua.DoString("a=TestClass.callOverridable(test,2,3)");
int a = (int)lua.GetNumber("a");
lua.DoString("luanet.free_object(test)");
Assert.Equal(6, a);
}
}