• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Lua类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: WriteChildFunctions

 private void WriteChildFunctions(Lua.Function function, int indentLevel = 0)
 {
     foreach(var f in function.functions)
     {
         Write(f, indentLevel + 1);
     }
 }
开发者ID:dabbertorres,项目名称:LuaDecompiler,代码行数:7,代码来源:Generator.cs


示例2: Start

	void Start () {
        Debug.Log("== 测试 ==   C#获取Lua对象引用");
        Lua lua = new Lua();
        lua["gameObject"] = gameObject;
        GameObject backRef = (GameObject)lua["gameObject"];
        Debug.Log(backRef.name);
	}
开发者ID:Henry-T,项目名称:UnityPG,代码行数:7,代码来源:LuaObjectGet.cs


示例3: Write

        public void Write(Lua.Function function, int indentLevel = 0)
        {
            // top level function
            if(function.lineNumber == 0 && function.lastLineNumber == 0)
            {
            //				WriteConstants(function);

                WriteChildFunctions(function);

                WriteInstructions(function);
            }
            else
            {
                string indents = new string('\t', indentLevel);

                string functionHeader = indents + "function func" + functionCount + "(";

                for(int i = 0; i < function.numParameters; ++i)
                {
                    functionHeader += "arg" + i + (i + 1 != function.numParameters ? ", " : ")");
                }

                writer.Write(functionHeader);
                ++functionCount;

            //				WriteConstants(function, indentLevel + 1);

                WriteChildFunctions(function, indentLevel + 1);

                WriteInstructions(function, indentLevel + 1);
            }
        }
开发者ID:dabbertorres,项目名称:LuaDecompiler,代码行数:32,代码来源:Generator.cs


示例4: LuaGlobalPortable

		/// <summary>Create a new environment for the lua script manager/compiler.</summary>
		/// <param name="lua">The lua script compiler.</param>
		public LuaGlobalPortable(Lua lua)
		{
			if (lua == null)
				throw new ArgumentNullException("lua");

			this.lua = lua;
		} // ctor
开发者ID:edisonh,项目名称:neolua,代码行数:9,代码来源:LuaGlobalPortable.cs


示例5: Init

            //Filename of the Lua file to load
            public static void Init()
            {
                if (_lua != null)
                {
                    return;
                }
                //Init instance of Lua virtual machine (Note: Can only init ONCE)
                _lua = new LuaInterface.Lua ();

                System.Type t = typeof(LuaManager);
                lua.RegisterFunction ("print", null, t.GetMethod ("LuaPrint"));
                lua.RegisterFunction ("error", null, t.GetMethod ("LuaError"));
                lua.RegisterFunction ("assert", null, t.GetMethod ("LuaAssert",
                                                                BindingFlags.Static | BindingFlags.Public,
                                                                System.Type.DefaultBinder,
                                                                new[] {
                    typeof(bool),
                    typeof(string)
                },
                                                                null)
                );
                lua.RegisterFunction ("require", null, t.GetMethod ("AddFilePath"));

                //Init LuaBinding class that demonstrates communication
                //Also tell Lua about the LuaBinding object to allow Lua to call C# functions
                mainBinding = new MainBinding ();
            }
开发者ID:Jay2645,项目名称:text-adventure,代码行数:28,代码来源:LuaManager.cs


示例6: CreateLuaVM

            private Lua CreateLuaVM()
            {
                Lua l = new Lua();
                Type t = GetType();
                MethodInfo m = t.GetMethod("WriteLog");
                l.RegisterFunction("Bot_PrintLog", this, m);

                m = t.GetMethod("Connect");
                l.RegisterFunction("Bot_Connect", this, m);

                m = t.GetMethod("Disconnect");
                l.RegisterFunction("Bot_Disconnect", this, m);

                m = t.GetMethod("SendPacket");
                l.RegisterFunction("Bot_SendPacket", this, m);

                m = t.GetMethod("StartTimer");
                l.RegisterFunction("Bot_StartTimer", this, m);

                m = t.GetMethod("ResetTimer");
                l.RegisterFunction("Bot_ResetTimer", this, m);

                m = t.GetMethod("StopTimer");
                l.RegisterFunction("Bot_StopTimer", this, m);

                m = t.GetMethod("GetTick");
                l.RegisterFunction("Bot_GetTick", this, m);

                return l;
            }
开发者ID:lythm,项目名称:orb3d,代码行数:30,代码来源:BotLuaApi.cs


示例7: Start

    void Start()
    {
        Debug.Log("== 测试 ==   C#获取Lua Float");
        Lua lua = new Lua();
        lua.DoString("num1 = -0.9999999");
        Debug.Log(lua["num1"]);
	}
开发者ID:Henry-T,项目名称:UnityPG,代码行数:7,代码来源:LuaFloatGet.cs


示例8: open

 public static void open(Lua.lua_State L)
 {
     Luna.dostring(L,"if __luna==nil then __luna={} end");
     Luna.dostring(L,"    if __luna.copyMethodsFrom==nil then\n        function __luna.copyMethodsFrom(methodsChild, methodsParent)\n            for k,v in pairs(methodsParent) do\n                if k~='__index' and k~='__newindex' and methodsChild[k]==nil then\n                    methodsChild[k]=v\n                end\n            end\n        end\n        function __luna.overwriteMethodsFrom(methodsChild, methodsParent)\n            for k,v in pairs(methodsParent) do\n                if k~='__index' and k~='__newindex' then\n                    if verbose then print('registering', k, methodsChild[k]) end\n                    methodsChild[k]=v\n                end\n            end\n        end\n    end\n    ");
     impl_LunaTraits_LWF_LWF.luna_init_hashmap();
     impl_LunaTraits_LWF_LWF.luna_init_write_hashmap();
     Luna_LWF_LWF.Register(L);
     Luna.dostring(L, "if not LWF then LWF={} end LWF.LWF=__luna.LWF_LWF");
     Luna.dostring(L,"                __luna.LWF_LWF.luna_class='.LWF'");
     impl_LunaTraits_LWF_Button.luna_init_hashmap();
     impl_LunaTraits_LWF_Button.luna_init_write_hashmap();
     Luna_LWF_Button.Register(L);
     Luna.dostring(L, "if not LWF then LWF={} end LWF.Button=__luna.LWF_Button");
     Luna.dostring(L,"                __luna.LWF_Button.luna_class='.Button'");
     impl_LunaTraits_LWF_Movie.luna_init_hashmap();
     impl_LunaTraits_LWF_Movie.luna_init_write_hashmap();
     Luna_LWF_Movie.Register(L);
     Luna.dostring(L, "if not LWF then LWF={} end LWF.Movie=__luna.LWF_Movie");
     Luna.dostring(L,"                __luna.LWF_Movie.luna_class='.Movie'");
     impl_LunaTraits_LWF_Point.luna_init_hashmap();
     impl_LunaTraits_LWF_Point.luna_init_write_hashmap();
     Luna_LWF_Point.Register(L);
     Luna.dostring(L, "if not LWF then LWF={} end LWF.Point=__luna.LWF_Point");
     Luna.dostring(L,"                __luna.LWF_Point.luna_class='.Point'");
 }
开发者ID:explodingbarrel,项目名称:lwf,代码行数:25,代码来源:lualwf.cs


示例9: close

 public static void close(Lua.lua_State L)
 {
     Luna_LWF_LWF.Unregister(L);
     Luna_LWF_Button.Unregister(L);
     Luna_LWF_Movie.Unregister(L);
     Luna_LWF_Point.Unregister(L);
 }
开发者ID:explodingbarrel,项目名称:lwf,代码行数:7,代码来源:lualwf.cs


示例10: Start

    public void Start()
    {
        //Init LuaBinding class that demonstrates communication
        LuaBinding binding = new LuaBinding();

        //Init instance of Lua virtual machine (Note: Can only init ONCE)
        luaVirtualMachine = new Lua();
        //Tell Lua about the LuaBinding object to allow Lua to call C# functions
        luaVirtualMachine["luabinding"] = binding;

        //test luabinding test
        LuaBindingTest bindingTest = LuaBindingTest.SharedInstance();
        bindingTest.name = "name1";
        luaVirtualMachine["LuaBindingTest"] = bindingTest;
        //luaVirtualMachine[""] = ;

        //Debug.LogError("LuaManager: " + Application.persistentDataPath);

        //Run the code contained within the file
        #if UNITY_ANDROID
        luaVirtualMachine.DoFile("/sdcard/Download/"+LuaFileToLoad);
        #else
        luaVirtualMachine.DoFile(Application.streamingAssetsPath+"/"+LuaFileToLoad);
        #endif
        //Trigger binding in c# to call the bound Lua function

        binding.MessageToLua();
        TestStaticFunction();
    }
开发者ID:haiweizhang,项目名称:UnityKopiLuaIntegration,代码行数:29,代码来源:LuaManager.cs


示例11: attachMovie

    public static int attachMovie(Lua.lua_State L)
    {
        LWF.Movie a;
        int args = Lua.lua_gettop(L);
        if (args < 3 || args > 6)
            goto error;
        if (Luna.get_uniqueid(L, 1) != LunaTraits_LWF_Movie.uniqueID)
            goto error;
        if (Lua.lua_isstring(L, 2)==0 || Lua.lua_isstring(L, 3)==0)
            goto error;
        if (args >= 4 && !Lua.lua_istable(L, 4))
            goto error;
        if (args >= 5 && Lua.lua_isnumber(L, 5)==0)
            goto error;
        if (args >= 6 && !Lua.lua_isboolean(L, 6))
            goto error;

        a = Luna_LWF_Movie.check(L, 1);
        return a.lwf.AttachMovieLua(a);

        error:
        Luna.printStack(L);
        Lua.luaL_error(L, "luna typecheck failed: LWF.Movie.attachMovie");
        return 1;
    }
开发者ID:KitoHo,项目名称:lwf,代码行数:25,代码来源:lwf_luabinding_lwf_movie.cs


示例12: TestGlobalMember01

 public void TestGlobalMember01()
 {
     using (Lua l = new Lua())
       {
     dynamic g = new LuaGlobalNew(l);
     TestResult(g.dochunk("return LogInfo('Hello');"), 3);
       }
 }
开发者ID:htwddwiedem,项目名称:neolua,代码行数:8,代码来源:Runtime.cs


示例13: IrcScriptEngine

 public IrcScriptEngine()
 {
     Engine = new Lua (
         integerType: LuaIntegerType.Int32,
         floatType: LuaFloatType.Float
     );
     LuaEnvironment = Engine.CreateEnvironment<LuaGlobal> ();
 }
开发者ID:SplittyDev,项目名称:DaBawd,代码行数:8,代码来源:IrcScriptEngine.cs


示例14: dostring

 public static void dostring(Lua.lua_State L, Lua.CharPtr luacode)
 {
     // Lua.luaL_dostring followed by pcall error checking
     if (Lua.luaL_dostring(L, luacode)==1)
     {
         print("Lua error: stack :");
         printStack(L,false);
     }
 }
开发者ID:explodingbarrel,项目名称:lwf,代码行数:9,代码来源:luna.cs


示例15: TestDynamic

		private static void TestDynamic()
		{
			var lua = new Lua();
			var global = new LuaGlobalPortable(lua) { ["workspace"] = new DynData() };

			var r = global.DoChunk("return workspace.Part", "Test.lua");

			Console.WriteLine(r.ToString());
		}
开发者ID:edisonh,项目名称:neolua,代码行数:9,代码来源:Program.cs


示例16: dostring

 public static void dostring(Lua.lua_State L, Lua.CharPtr luacode)
 {
     // Lua.luaL_dostring followed by pcall error checking
     if (Lua.luaL_loadstring(L, luacode) != 0 || Lua.lua_pcall(L, 0, Lua.LUA_MULTRET, 0) != 0)
     {
         print("Lua error: stack :");
         printStack(L,false);
     }
 }
开发者ID:ruipengliu,项目名称:lwf,代码行数:9,代码来源:luna.cs


示例17: LibraryTestBase

 protected LibraryTestBase()
 {
     Lua = new Lua();
     Lua.Register((Action<object, object, string>)Assert.AreEqual, "assertEquals");
     Lua.Register((Action<bool, string>)Assert.IsTrue, "assertTrue");
     Lua.Register((Action<bool, string>)Assert.IsFalse, "assertFalse");
     Lua.Register((Action<double, double, string>)assertEqualsDelta);
     Lua.Register((Action<string>)Assert.Fail, "fail");
     Lua.Register(typeof(UserData));
 }
开发者ID:TheModMaker,项目名称:ModMaker.Lua,代码行数:10,代码来源:LibraryTestBase.cs


示例18: _bind_ctor

    public static LWF.Point _bind_ctor(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L)!= 0) return _bind_ctor_overload_1(L);
        if (Lua.lua_gettop(L)!= 2
            || Lua.lua_isnumber(L, 1)==0
            || Lua.lua_isnumber(L, 2)==0) return _bind_ctor_overload_2(L);
        Lua.luaL_error(L, "ctor ( cannot find overloads:)");

        return null;
    }
开发者ID:ruipengliu,项目名称:lwf,代码行数:10,代码来源:lwf_luabinding_lwf_point.cs


示例19: TestGlobalProperty01

        public void TestGlobalProperty01()
        {
            using (Lua l = new Lua())
            {
                var g = l.CreateEnvironment<LuaGlobalNew>();

                g.DoChunk("BoolProperty = true", "test1.lua");
                TestResult(g.DoChunk("return BoolProperty", "test2.lua"), true);
            }
        }
开发者ID:htwddwiedem,项目名称:neolua,代码行数:10,代码来源:Runtime.cs


示例20: Start

	void Start()
	{
		_lua = new Lua();
		_lua.DoString("UnityEngine = luanet.UnityEngine");
		_lua.DoString("System = luanet.System");
		_lua["gameObject"] = this;
		
		Code = "function update(dt)\n\nend\n";
		
		DoCode(Code);
	}
开发者ID:drakelinglabs,项目名称:unityarmada,代码行数:11,代码来源:Controller.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LuaCSFunction类代码示例发布时间:2022-05-24
下一篇:
C# LruCache类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap