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


C# Lua.LoadCLRPackage方法代码示例

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


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

示例1: InitEditorState

        private static void InitEditorState(Lua state)
        {
            state.LoadCLRPackage();

            string resName = "WorldSmith.Scripts.WorldsmithImports.lua";

            Assembly asm = Assembly.GetExecutingAssembly();
            using (System.IO.Stream s = asm.GetManifestResourceStream(resName))
            using (System.IO.StreamReader reader = new System.IO.StreamReader(s))
            {
                string data = reader.ReadToEnd();

                state.DoString(data, resName);               
            }

            state["Units"] = DotaData.AllUnits;          
            state["Heroes"] = DotaData.AllHeroes;          
            state["Abilities"] = DotaData.AllAbilities;           
            state["Items"] = DotaData.DefaultItems;
            state["Events"] = DotaData.Events;

            //Bind the DataClass enum
            state.DoString("DataClass = {}");
            state["DataClass.Default"] = DotaDataObject.DataObjectInfo.ObjectDataClass.Default;
            state["DataClass.Override"] = DotaDataObject.DataObjectInfo.ObjectDataClass.Override;
            state["DataClass.Custom"] = DotaDataObject.DataObjectInfo.ObjectDataClass.Custom;


        }
开发者ID:Oplkill,项目名称:WorldSmith,代码行数:29,代码来源:LuaHelper.cs

示例2: Init

        public void Init()
        {
            if (IsInitialized)
                throw new InvalidOperationException("Already Initialized!");

            if (_state != null) _state.Dispose();
            
            _state = new Lua();
            _state.LoadCLRPackage();

            _state.DoString(@"luanet.load_assembly('WGestures.Core');
                              luanet.load_assembly('WindowsInput');
                              luanet.load_assembly('WGestures.Common');

                              GestureModifier=luanet.import_type('WGestures.Core.GestureModifier');  
                              VK=luanet.import_type('WindowsInput.Native.VirtualKeyCode');
                              Native=luanet.import_type('WGestures.Common.OsSpecific.Windows.Native');
                            ", "_init");

            _state["Input"] = Sim.Simulator;
            _state.RegisterFunction("ReportStatus", this, typeof(ScriptCommand).GetMethod("OnReportStatus"));

            if(InitScript != null)
            {
                DoString(InitScript, "Init");
            }
            
            IsInitialized = true;
        }
开发者ID:huipengly,项目名称:WGestures,代码行数:29,代码来源:ScriptCommand.cs

示例3: Start

	void Start()
	{
		lua = new NLua.Lua();
		lua.LoadCLRPackage();
		var method = typeof(Debug).GetMethod("Log", new Type[] { typeof(object) });
		lua.RegisterFunction("print", method);
	}
开发者ID:wuzhangwuzhang,项目名称:BWM,代码行数:7,代码来源:LuaTest.cs

示例4: Awakening

        public bool Awakening()
        {
            spaar.ModLoader.Game.OnSimulationToggle += GameOnOnSimulationToggle;
            spaar.ModLoader.Game.OnLevelWon += GameOnOnLevelWon;
            env = new NLua.Lua();
            env.LoadCLRPackage();
            env["this"] = this; // Give the script access to the gameobject.
            env["transform"] = transform;
            env["gameObject"] = gameObject;
            env["enabled"] = enabled;
            env["useAPI"] = new Action(UseAPI);
            env["disableAPI"] = new Action(DisableAPI);

            if (Settings.useAPI)
            {
                Besiege.SetUp();
                env["besiege"] = Besiege._besiege;
            }
            try
            {
                env.DoString(source);
            }
            catch (NLua.Exceptions.LuaException e)
            {
                Debug.LogError(FormatException(e), context: gameObject);
                return false;
            }
            Call("Awake");
            return true;
        }
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:30,代码来源:LuaBehaviour.cs

示例5: TestBinaryLoadFile

		public void TestBinaryLoadFile ()
		{
			using (Lua lua = new Lua ()) {
				lua.LoadCLRPackage ();
				if (IntPtr.Size == 4)
					lua.DoFile ("test_32.luac");
				else
					lua.DoFile ("test_64.luac");

				int width = (int)(double)lua ["width"];
				int height = (int)(double)lua ["height"];
				string message = (string)lua ["message"];
				int color_g	= (int)(double)lua ["color.g"];
				LuaFunction func = (LuaFunction)lua ["func"];
				object[] res = func.Call (12, 34);
				int x = (int)(double)res [0];
				int y = (int)(double)res [1];
				//function func(x,y)
				//	return x,x+y
				//end

				Assert.AreEqual (100, width);
				Assert.AreEqual (200, height);
				Assert.AreEqual ("Hello World!", message);
				Assert.AreEqual (20, color_g);
				Assert.AreEqual (12, x);
				Assert.AreEqual (46, y);
			}
		}
开发者ID:mMellowz,项目名称:revcore,代码行数:29,代码来源:LoadFileTests.cs

示例6: ScriptComponent

        public ScriptComponent()
        {
            Family = ComponentFamily.Script;

            lua = new Lua();
            lua.LoadCLRPackage();
        }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:7,代码来源:Script.cs

示例7: Start

        void Start()
        {
			LuaState = new Lua();
			LuaState.LoadUnityExpand();
			LuaState.LoadImportExpand();
			LuaState.LoadCLRPackage("Using");

			LuaState.CallLunaFunction("lunatest.lua", "Start", this.gameObject);
			LuaState.CheckStack();
        }
开发者ID:SD-J,项目名称:UnityLua,代码行数:10,代码来源:LunaExample.cs

示例8: Main

		static void Main (string [] args)
		{
			using (var l = new Lua ()) {
				l.LoadCLRPackage ();
				l.DoString (" import ('ConsoleTest') ");
				l.DoString (@"
						Program.Method (1)
				");
			}
		}
开发者ID:radiaku,项目名称:NLua,代码行数:10,代码来源:Program.cs

示例9: Start

		void Start()
		{
			LuaState = new Lua();
			LuaState.LoadCLRPackage();
			LuaState.LoadUnityExpand();

			var ret = LuaState.DoString(@"return require 'requiretest'");
			TestLib = ret[0] as LuaTable;

			var startCallback = TestLib["Start"] as LuaFunction;
			startCallback.Call(this.gameObject);
		}
开发者ID:SD-J,项目名称:UnityLua,代码行数:12,代码来源:RequireExample.cs

示例10: Awake

    void Awake() {
		env = new Lua();
		env.LoadCLRPackage();
		
		env["this"] = this; // Give the script access to the gameobject.
		env["transform"] = transform;
        env["cube"] = cube;
        env["btnObj"] = btnObj;
        env["Sphere"] = Sphere;
        StartCoroutine(loadLua());
               
	}
开发者ID:hanbim520,项目名称:UFLua,代码行数:12,代码来源:ExampleBehaviour.cs

示例11: Main

		static void Main (string [] args)
		{
			using (var l = new Lua ()) {
				l.LoadCLRPackage ();
				l.DoString (" import ('ConsoleTest', 'NLuaTest.Mock') ");
				l.DoString (@"
						e1 = Entity()
						e2 = Entity ('Another world')
						e3 = Entity (10)
				");
			}
		}
开发者ID:zhangf911,项目名称:NLua,代码行数:12,代码来源:Program.cs

示例12: TestCLRPackage

		public void TestCLRPackage ()
		{
			using (Lua lua = new Lua ()) {
				lua.LoadCLRPackage ();

				lua.DoString ("import ('NLuaTest', 'NLuaTest.Mock') ");
				lua.DoString ("test = TestClass()");
				lua.DoString ("test:setVal(3)");
				object[] res = lua.DoString ("return test");
				TestClass test = (TestClass)res [0];
				Assert.AreEqual (3, test.testval);
			}
		}
开发者ID:BlackNecro,项目名称:NLua,代码行数:13,代码来源:NLuaTests.cs

示例13: TestUseNSUrl

		public void TestUseNSUrl ()
		{
			using (Lua lua = new Lua ()) {
				lua.LoadCLRPackage ();

				lua.DoString ("import ('monotouch', 'MonoTouch.Foundation') ");
				lua.DoString ("testURL = NSUrl('http://nlua.org/?query=param')");
				lua.DoString ("host = testURL.Host");

				object res = lua["host"];
				string host = (string)res;
				Assert.AreEqual ("nlua.org", host);
			}
		}
开发者ID:BlackNecro,项目名称:NLua,代码行数:14,代码来源:NLuaTests.cs

示例14: runLua

 public static void runLua(String code)
 {
     try
     {
         Lua vm = new Lua();
         vm.InstallRunGNatives();
         if (Static.isCLR) vm.LoadCLRPackage();
         vm.DoString(code);
     }
     catch (Exception e)
     {
         log.error("Erro: " + RunGEngine.decipherCatch(e));
         Static.fine = false;
     }
 }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:15,代码来源:RunGEngine.cs

示例15: executeCommand

 /// <summary>
 /// Try to execute a Lua command given in a string
 /// </summary>
 /// <param name="luaCommand"></param>
 public static bool executeCommand(string luaCommand)
 {
     Lua lua = new Lua();
     lua.LoadCLRPackage();
     lua.DoString(@" import ('TextRPG', 'TextRPG')
        import ('System') ");
     try {
         lua.DoString(luaCommand);
         return true;
     }
     catch (Exception e)
     {
         return false;
     }
 }
开发者ID:Gokimster,项目名称:Dissertation,代码行数:19,代码来源:LuaManager.cs


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