public LuaWrapper() { lua.SetDebugHook(NLua.Event.EventMasks.LUA_MASKLINE, 1); lua.LoadCLRPackage(); Scriptmgr = ScriptHelpMgr.Instance; RegistAllFunction(); }
private void SetInitialState() { State = new NLua.Lua(); State.LoadCLRPackage(); State.DoString(@"import ('World','World.ToyWorldCore')"); State.DoString(@"import ('World','World.Lua')"); State["le"] = this; State["atlas"] = m_atlas; State.RegisterFunction("Help", typeof(LuaExecutor).GetMethod("Help")); if (m_atlas.Avatars.Count > 0) { AvatarCommander avatarCommander = new AvatarCommander(this, m_atlas); State["ac"] = avatarCommander; } AtlasManipulator atlasManipulator = new AtlasManipulator(m_atlas); State["am"] = atlasManipulator; State["lc"] = m_luaConsole; State.DebugHook += OnDebugHook; State.SetDebugHook(EventMasks.LUA_MASKLINE, 1000); }
public void ProvideInfoToLua(NLua.Lua L) { L.LoadCLRPackage(); L.DoString("import ('The betrayer', 'TBAGW.Utilities') "); L["provisionState"] = this; L["provisionData"] = data; }
private void CheckLuaScript() { if (expScript == null && !loc.Equals("") && !funcName.Equals("")) { try { expScript = new NLua.Lua(); expScript.LoadCLRPackage(); expScript.DoFile(Game1.rootContent + loc); bHasProperLua = expScript.GetFunction(funcName) != null; } catch (Exception e) { bHasProperLua = false; expScript = null; if (Game1.bIsDebug) { Console.WriteLine(e); //throw e; } } } else if (loc.Equals("")) { bHasProperLua = false; expScript = null; } else if (!bHasProperLua) { expScript = null; bHasProperLua = false; } }
protected override void Initialized(object state) { base.Initialized(state); if (_ctx != null) { _ctx.Dispose(); } _ctx = new NLua.Lua(); _ctx.LoadCLRPackage(); _ctx.RegisterFunction("AddCommand", this, this.GetType().GetMethod("AddCommand")); _ctx.RegisterFunction("ArraySort", this, this.GetType().GetMethod("ArraySort")); //_ctx.RegisterFunction("HookBase", this, this.GetType().GetMethods() // .Where(x => x.Name == "HookBase" && x.GetParameters().Last().ParameterType == typeof(NLua.LuaFunction)) // .First()); _ctx.DoFile(Path); CallSelf("Initialized"); var plg = _ctx["export"] as NLua.LuaTable; if (plg != null) { this.TDSMBuild = (int)(double)plg["TDSMBuild"]; this.Author = plg["Author"] as String; this.Description = plg["Description"] as String; this.Name = plg["Name"] as String; this.Version = plg["Version"] as String; IsValid = true; var hooks = plg["Hooks"] as NLua.LuaTable; if (hooks != null) { foreach (KeyValuePair <Object, Object> hookTarget in hooks) { var hook = hookTarget.Key as String; var hookPoint = PluginManager.GetHookPoint(hook); if (hookPoint != null) { var details = hookTarget.Value as NLua.LuaTable; var priority = (HookOrder)(details["Priority"] ?? HookOrder.NORMAL); //var priority = FindOrder(details["Priority"] as String); var del = _ctx.GetFunction(hookPoint.DelegateType, "export.Hooks." + hook + ".Call"); HookBase(hookPoint, priority, del); //TODO maybe fake an actual delegate as this is only used for registering or make a TDSM event info class } } } } }
public LuaState(object input = null) { lua.State.Encoding = Encoding.UTF8; lua.LoadCLRPackage(); if (input != null) { lua["input"] = input; } lua["@this"] = this; Init(); }
public LuaExecutionEngine(string script) { if (script == null) { throw new ArgumentNullException("script"); } _script = script; _lua = new NLua.Lua(); _lua.LoadCLRPackage(); _lua.DoString(script); }
/// <summary> /// 初始化,加载全部接口 /// </summary> /// <param name="input">输入值,一般为匿名类</param> public LuaTask(object input = null) { lua = new NLua.Lua(); lua.State.Encoding = Encoding.UTF8; lua.LoadCLRPackage(); if (input != null) { lua["input"] = input;//传递输入值 } lua.DoString(sysCode); lua["@this"] = this;//自己传给自己 }
public void Test() { using (var lua = new NLua.Lua()) { lua.LoadCLRPackage(); lua.DoString("luanet.load_assembly('mscorlib')"); lua.DoString("luanet.load_assembly('System.Windows.Forms')"); lua.DoString("a=luanet.import_type('System.Window.Forms.MessageBox')"); lua.DoString("a.Show('lua')"); Console.Read(); } }
public void Test() { using (var lua = new NLua.Lua()) { lua.LoadCLRPackage(); lua.RegisterFunction("Calc", null, typeof(Out_Test).GetMethod("Calc")); lua.DoString("a,b,c,e=Calc(10,2)"); double a = (double)lua["a"]; double b = (double)lua["b"]; double c = (double)lua["c"]; string e = (string)lua["e"]; lua.DoString("print('this is from lua print')"); Console.WriteLine("a:{0},b:{1},c:{2},e:{3}", a, b, c, e); Console.Read(); } }
/// <summary> /// 在沙盒中运行代码,仅允许安全地运行 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string RunSandBox(string code) { using var lua = new NLua.Lua(); try { lua.State.Encoding = Encoding.UTF8; lua.LoadCLRPackage(); lua["lua_run_result_var"] = "";//返回值所在的变量 lua.DoFile(Path + "lua/sandbox/head.lua"); lua.DoString(code); return(lua["lua_run_result_var"].ToString()); } catch (Exception e) { Log.Warn("lua沙盒错误", e.Message); return("运行错误:" + e.ToString()); } }
/// <summary> /// 在沙盒中运行代码,仅允许安全地运行 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string RunSandBox(string code) { using var lua = new NLua.Lua(); try { lua.State.Encoding = Encoding.UTF8; lua.LoadCLRPackage(); lua["lua_run_result_var"] = "";//返回值所在的变量 lua.DoFile(Common.AppData.CQApi.AppDirectory + "lua/sandbox/main.lua"); lua.DoString(code); return(lua["lua_run_result_var"].ToString()); } catch (Exception e) { Common.AppData.CQLog.Warning("lua沙盒错误", e.Message); return("运行错误:" + e.ToString()); } }
public void Test() { using (var lua = new NLua.Lua()) { lua.State.Encoding = Encoding.UTF8; lua.LoadCLRPackage(); lua.DoString(@" import 'System.Windows.Forms'; frm=Form(); frm.Text='new form'; frm.Load:Add(function(sender,e) MessageBox.Show('窗体加载'); end) frm:ShowDialog(); "); Console.Read(); } }
public void Test() { using (var lua = new NLua.Lua()) { lua.LoadCLRPackage(); lua.RegisterFunction("Calc", null, typeof(ref_Test).GetMethod("Calc")); lua.DoString("a=1;b=2;c=3;d=4;e=nil;"); lua.DoString("result,c,d,e=Calc(a,b,c,d,e)"); double a = (double)lua["a"]; double b = (double)lua["b"]; double c = (double)lua["c"]; double d = (double)lua["d"]; string e = (string)lua["e"]; lua.DoString("print('this is from lua print')"); Console.WriteLine("a:{0},b:{1},c:{2},d:{3},e:{4}", a, b, c, d, e); Console.WriteLine(lua["result"]); Console.Read(); } }
public bool HasProperLua() { bool temp = false; if (!luaLoc.Equals("")) { try { luaState = new NLua.Lua(); luaState.LoadCLRPackage(); luaState.DoFile(Game1.rootContent + luaLoc); return(true); } catch (Exception) { } } return(temp); }
internal bool CheckScript() { if (scriptFunction.Equals("")) { return(false); } else if (!scriptLoc.Equals("")) { NLua.Lua state = new NLua.Lua(); state.LoadCLRPackage(); try { state.DoFile(Game1.rootContent + scriptLoc); } catch (Exception) { script = null; return(false); } bool bIsCorrectScriptAndFunction = state.GetFunction(scriptFunction) != null; if (bIsCorrectScriptAndFunction) { script = state; if (!modFunctionName.Equals("")) { modFunction = state.GetFunction(modFunctionName); } else { modFunction = null; } return(true); } return(false); } return(false); }
public void CheckScript() { if (!functionName.Equals("") && levelUpScript == null && !scriptLoc.Equals("") || (bRecheckScript && !scriptLoc.Equals(""))) { try { levelUpScript = new NLua.Lua(); levelUpScript.LoadCLRPackage(); levelUpScript.DoFile(Game1.rootContent + scriptLoc); } catch (Exception e) { levelUpScript = null; } } if (levelUpScript != null) { bHasProperScript = levelUpScript.GetFunction(functionName) != null; } bHasProperScript = levelUpScript != null; }
internal void Execute(LuaTurnSetInfo ltsi) { if (state == null) { state = new NLua.Lua(); state.LoadCLRPackage(); if (fileNameLoc.StartsWith(@"\")) { fileNameLoc = fileNameLoc.Remove(0, 1); } String comp = System.IO.Path.Combine(TBAGW.Game1.rootContent, fileNameLoc); state.DoFile(comp); } if (state.GetFunction(functionName) != null) { if (bNoParameter) { (state[functionName] as NLua.LuaFunction).Call(); } else if (!bNoParameter) { //var temp = ltsi.otherGroups[0].RandomMember(); if (eventType == EventType.updateEV) { (state[functionName] as NLua.LuaFunction).Call(ltsi, msTime); } else { (state[functionName] as NLua.LuaFunction).Call(ltsi); } } } else { Console.WriteLine("Lua error from " + fileNameLoc + " , @function-name " + functionName); eventType = EventType.None; } }
public void Test() { using (var lua = new NLua.Lua()) { lua.State.Encoding = Encoding.Default; lua.LoadCLRPackage(); #region 方式一 //lua.DoString("import 'System.Windows.Forms'"); //lua.DoString("MessageBox.Show('lua脚本')"); #endregion #region 方式二 //lua.DoString("System={}"); //lua.DoString("System.Windows={}"); //lua.DoString("System.Windows.Forms=import 'System.Windows.Forms'"); //lua.DoString("System.Windows.Forms.MessageBox.Show('lua脚本','提示')"); #endregion #region 方式三 lua.DoString("package.path=package.path..';'..'./Script/?.lua'"); lua.DoString("json= require 'json'"); lua.DoString("System={}"); lua.DoString("System.Windows={}"); lua.DoString("System.Windows.Forms=import 'System.Windows.Forms'"); lua.DoString("print(json.encode(System))"); LuaTable table = lua["_G"] as LuaTable; lua.DoString("System.Windows.Forms.MessageBox.Show('lua脚本','提示')"); #endregion Console.Read(); } }
/// <summary> /// 运行lua文件 /// </summary> /// <param name="code">提前运行的代码</param> /// <param name="file">文件路径(app/xxx.xxx.xx/lua/开头)</param> public static bool RunLua(string code, string file, ArrayList args = null) { //还没下载lua脚本,先不响应消息 if (!File.Exists(Common.AppDirectory + "lua/require/head.lua")) { return(false); } using (var lua = new NLua.Lua()) { try { lua.State.Encoding = Encoding.UTF8; lua.LoadCLRPackage(); lua["handled"] = false;//处理标志 Initial(lua); if (args != null) { for (int i = 0; i < args.Count; i += 2) { lua[(string)args[i]] = args[i + 1]; } } lua.DoString(code); if (file != "") { lua.DoFile(Common.AppDirectory + "lua/" + file); } return((bool)lua["handled"]); } catch (Exception e) { Common.CqApi.AddLoger(Sdk.Cqp.Enum.LogerLevel.Error, "lua脚本错误", e.ToString()); return(false); } } }
/// <summary> /// 运行lua文件 /// </summary> /// <param name="code">提前运行的代码</param> /// <param name="file">文件路径(app/xxx.xxx.xx/lua/开头)</param> public static bool RunLua(string code, string file) { using (var lua = new NLua.Lua()) { try { lua.State.Encoding = Encoding.UTF8; lua.LoadCLRPackage(); lua["handled"] = false;//处理标志 Initial(lua); lua.DoString(code); if (file != "") { lua.DoFile(Common.AppDirectory + "lua/" + file); } return((bool)lua["handled"]); } catch (Exception e) { Common.CqApi.AddLoger(Sdk.Cqp.Enum.LogerLevel.Error, "lua脚本错误", e.ToString()); return(false); } } }
public void UpdateCoroutines() { using (var lua = new NLua.Lua()) { lua.LoadCLRPackage(); lua.LoadCoroutineManager(); lua.DoString("function test() return 'hi' end " + "function test2() coroutine.yield() return true end " + "function test3() return 3,4 end"); lua.CreateCoroutine("test"); lua.CreateCoroutine("test2"); lua.CreateCoroutine("test3"); Dictionary<string, LuaCoroutineResult> results = lua.UpdateCoroutines(); Assert.IsTrue(results["test"].IsValid); Assert.IsTrue((string)results["test"].Results[0] == "hi"); Assert.IsTrue(lua.StatusCoroutine("test") == LuaCoroutineStatus.Dead); Assert.IsTrue(results["test2"].IsValid); Assert.IsTrue(lua.StatusCoroutine("test2") == LuaCoroutineStatus.Suspended); Assert.IsTrue(results["test3"].IsValid); Assert.IsTrue((int)(double)results["test3"].Results[0] == 3); Assert.IsTrue((int)(double)results["test3"].Results[1] == 4); Assert.IsTrue(lua.StatusCoroutine("test3") == LuaCoroutineStatus.Dead); results = lua.UpdateCoroutines(); Assert.IsFalse(results["test"].IsValid); Assert.IsTrue(lua.StatusCoroutine("test") == LuaCoroutineStatus.Dead); Assert.IsTrue(results["test2"].IsValid); Assert.IsTrue((bool)results["test2"].Results[0]); Assert.IsTrue(lua.StatusCoroutine("test2") == LuaCoroutineStatus.Dead); Assert.IsFalse(results["test3"].IsValid); Assert.IsTrue(lua.StatusCoroutine("test3") == LuaCoroutineStatus.Dead); } }
private void SetLuaEnv() { try { luaEngine.State.Encoding = Encoding.UTF8; luaEngine.LoadCLRPackage(); helpInfo += "CLR package is loaded, using:\r\nimport ('System.Web');\r\nlocal client = WebClient()\r\n\r\n"; // Keys luaEngine.DoString("Keys={};"); foreach (Keys key in Enum.GetValues(typeof(Keys))) { luaEngine.DoString($"Keys[\"{key.ToString()}\"]={(int)key};"); } helpInfo += "Keys[] is a table containing .Net Windows.Forms.Keys enum values\r\n\r\n"; // Moving luaEngine.RegisterFunction(nameof(Move2D), this, GetType().GetMethod(nameof(Move2D))); helpInfo += "void Move2D(table points) - something like { {[\"X\"] = 5673.50244, [\"Y\"] = 4510.01953, [\"Z\"] = 125.027237}, {[\"X\"] = 5680.97363, [\"Y\"] = 4487.585, [\"Z\"] = 130.122177} }\r\n"; // game luaEngine.RegisterFunction("UseItemByID", info, typeof(GameInterface).GetMethod("UseItemByID")); helpInfo += "void UseItemByID(uint id)\r\n"; luaEngine.RegisterFunction("UseItem", info, typeof(GameInterface).GetMethod("UseItem")); helpInfo += "void UseItem(int bagID, int slotID)\r\n"; luaEngine.RegisterFunction("CastSpellByName", info, typeof(GameInterface).GetMethod("CastSpellByName")); helpInfo += "void CastSpellByName(string spellName)\r\n"; luaEngine.RegisterFunction("SelectDialogOption", info, typeof(GameInterface).GetMethod("SelectDialogOption")); helpInfo += "void SelectDialogOption(string gossipText)\r\n"; luaEngine.RegisterFunction("BuyMerchantItem", info, typeof(GameInterface).GetMethod("BuyMerchantItem")); helpInfo += "void BuyMerchantItem(uint itemID, int count)\r\n"; luaEngine.RegisterFunction("SendToChat", info, typeof(GameInterface).GetMethod("SendToChat")); helpInfo += "void SendToChat(string command)\r\n"; // Info luaEngine.RegisterFunction(nameof(IsInGame), this, GetType().GetMethod(nameof(IsInGame))); helpInfo += "bool IsInGame()\r\n"; luaEngine.RegisterFunction(nameof(IsLoadingScreenVisible), this, GetType().GetMethod(nameof(IsLoadingScreenVisible))); helpInfo += "bool IsLoadingScreenVisible()\r\n"; luaEngine.RegisterFunction(nameof(MouseoverGUID), this, GetType().GetMethod(nameof(MouseoverGUID))); helpInfo += "string MouseoverGUID()\r\n"; luaEngine.RegisterFunction(nameof(IsSpellKnown), this, GetType().GetMethod(nameof(IsSpellKnown))); helpInfo += "bool IsSpellKnown(double spellID)\r\n"; luaEngine.RegisterFunction(nameof(IsLooting), this, GetType().GetMethod(nameof(IsLooting))); helpInfo += "bool IsLooting()\r\n"; luaEngine.RegisterFunction(nameof(ZoneID), this, GetType().GetMethod(nameof(ZoneID))); helpInfo += "double ZoneID()\r\n"; luaEngine.RegisterFunction(nameof(ZoneText), this, GetType().GetMethod(nameof(ZoneText))); helpInfo += "string ZoneText()\r\n"; luaEngine.RegisterFunction(nameof(Lua_GetValue), this, GetType().GetMethod(nameof(Lua_GetValue))); helpInfo += "string Lua_GetValue(string func)\r\n"; luaEngine.RegisterFunction(nameof(Lua_IsTrue), this, GetType().GetMethod(nameof(Lua_IsTrue))); helpInfo += "bool Lua_IsTrue(string condition)\r\n"; // Objects luaEngine.RegisterFunction(nameof(GetLocalPlayer), this, GetType().GetMethod(nameof(GetLocalPlayer))); helpInfo += "uservalue WoWPlayerMe GetLocalPlayer()\r\n"; luaEngine.RegisterFunction(nameof(GetNpcs), this, GetType().GetMethod(nameof(GetNpcs))); helpInfo += "double, uservalue List<WowNpc> GetNpcs()\r\n"; luaEngine.RegisterFunction(nameof(GetPlayers), this, GetType().GetMethod(nameof(GetPlayers))); helpInfo += "double, uservalue List<WowPlayer> GetPlayers()\r\n"; luaEngine.RegisterFunction(nameof(GetObjects), this, GetType().GetMethod(nameof(GetObjects))); helpInfo += "double, uservalue List<WowObject> GetObjects()\r\n"; luaEngine.RegisterFunction(nameof(GetTargetObject), this, GetType().GetMethod(nameof(GetTargetObject))); helpInfo += "uservalue dynamic GetTargetObject()\r\n"; // utilities luaEngine.RegisterFunction(nameof(MsgBox), this, GetType().GetMethod(nameof(MsgBox))); helpInfo += "void MsgBox(object text)\r\n"; luaEngine.RegisterFunction("PressKey", info, info.GetType().GetMethod("PressKey")); helpInfo += "void PressKey(int key)\r\n"; luaEngine.RegisterFunction(nameof(Log), this, GetType().GetMethod(nameof(Log))); helpInfo += "void Log(object text)\r\n"; luaEngine.RegisterFunction(nameof(Wait), this, GetType().GetMethod(nameof(Wait))); helpInfo += "void Wait(double ms) - this method contains call to StopExecutionIfCancellationRequested()\r\n"; luaEngine.RegisterFunction(nameof(NotifyUser), this, GetType().GetMethod(nameof(NotifyUser))); helpInfo += "void NotifyUser(object text)\r\n"; luaEngine.RegisterFunction(nameof(StopExecutionIfCancellationRequested), this, GetType().GetMethod(nameof(StopExecutionIfCancellationRequested))); helpInfo += "bool StopExecutionIfCancellationRequested()\r\n"; luaEngine.RegisterFunction("GetUIFrameByName", info, info.GetType().GetMethod("GetUIFrameByName")); helpInfo += "uservalue<WoWUIFrame> GetUIFrameByName(string frameName)\r\n"; // lua lib luaEngine.DoString("format=string.format;"); luaEngine.DoString("if (not table.count) then table.count = function(tbl) local count = 0; for index in pairs(tbl) do count = count+1; end return count; end end"); luaEngine.DoString("if (not table.first) then table.first = function(tbl) for _, value in pairs(tbl) do return value; end end end"); helpInfo += "real table.count(tbl)\r\nvalue table.first(tbl)\r\n"; luaEngine.DoString(GetNearestObjectByName); helpInfo += "uservalue WowNpc/WowObject/WowPlayer GetNearestObjectByName(listLength, list, name)\r\n"; luaEngine.DoString("print = function(...) local text = \"\"; for i = 1, select(\"#\", ...) do text = text..tostring(select(i, ...))..\" \" end SendToChat(\"/run print(\"..text..\")\"); end"); helpInfo += "void print(params string)\r\n"; } catch (Exception ex) { MsgBox(ex.Message); } }
public void LoadCLRPackage() { mLua.LoadCLRPackage(); }
public void SleepCoroutine() { using (var lua = new NLua.Lua()) { lua.LoadCLRPackage(); lua.LoadCoroutineManager(); lua.DoString("function test() coroutine.manager.sleep(10, 'stopped 1') return 'hi' end " + "function test2() coroutine.manager.sleep(20, 'stopped 2') return 'hello' end "); lua.CreateCoroutine("test"); lua.CreateCoroutine("test2"); Dictionary<string, LuaCoroutineResult> results = lua.UpdateCoroutines(); Assert.IsTrue(results["test"].IsValid); Assert.IsTrue((string)results["test"].Results[0] == "stopped 1"); Assert.IsTrue(lua.StatusCoroutine("test") == LuaCoroutineStatus.Sleeping); Assert.IsTrue(results["test2"].IsValid); Assert.IsTrue((string)results["test2"].Results[0] == "stopped 2"); Assert.IsTrue(lua.StatusCoroutine("test2") == LuaCoroutineStatus.Sleeping); results = lua.UpdateCoroutines(10); Assert.IsTrue(results["test"].IsValid); Assert.IsTrue((string)results["test"].Results[0] == "hi"); Assert.IsTrue(lua.StatusCoroutine("test") == LuaCoroutineStatus.Dead); Assert.IsTrue(results["test2"].IsValid); Assert.IsTrue(lua.StatusCoroutine("test2") == LuaCoroutineStatus.Sleeping); results = lua.UpdateCoroutines(10); Assert.IsFalse(results["test"].IsValid); Assert.IsTrue(lua.StatusCoroutine("test") == LuaCoroutineStatus.Dead); Assert.IsTrue(results["test2"].IsValid); Assert.IsTrue((string)results["test2"].Results[0] == "hello"); Assert.IsTrue(lua.StatusCoroutine("test2") == LuaCoroutineStatus.Dead); } }
public static void Test() { NLua.Lua state = new NLua.Lua(); NLua.Lua state2 = new NLua.Lua(); someData sd = new someData(); sd.ID = 25; sd.sList.AddRange(new String[] { "this", " is", " a", " test", " list" }); luaData ld = new luaData(sd); //var test = state.DoString("return 10 + 3*(5 + 2)")[0]; //var type = test.GetType(); //int value = 6; //state["test"] = value; //var result = state.DoString("return test*3+(test-3)")[0]; //state.DoString(@" // function ScriptFunc (val1, val2) // val1=val1+2 // val2=val2+3 // return val1, val2 // end"); //var scriptFunc = state["ScriptFunc"] as NLua.LuaFunction; //var res = scriptFunc.Call(3, 5); testClass tc = new testClass("Some test string here"); tc.list.Add(25); state["provision"] = "Random piece of information"; testClass tc2 = new testClass("Indirect summon"); tc2.data = ld; tc2.ProvideInfoToLua(state); //state["testObj"] = tc; state.LoadCLRPackage(); // state.DoString(@" import ('The betrayer', 'TBAGW.Utilities') // import ('System.Web') // import ('System')"); // var testStringFromObject = state.DoString("return TestObject.testList[0]")[0]; // var elementType = testStringFromObject.GetType(); // testClass testObjFromLUA = state.DoString("return TestObject")[0] as testClass; //bool bWhat = testObjFromLUA.GetType() == tc.GetType(); state.DoString("print(\"Hello World\")"); System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); ofd.Filter = "LUA files (*.lua)|*.lua"; ofd.InitialDirectory = Game1.rootContent; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { state = new NLua.Lua(); state.LoadCLRPackage(); state.DoFile(ofd.FileName); var time = System.IO.File.GetLastWriteTime(ofd.FileName); } //var statsTest = ((state["generateSomeStats"] as NLua.LuaFunction).Call()[0] as LuaStatEdit).ExtractStatChart(); //BaseSprite bs = new BaseSprite(); //bs.position = new Vector2(136, 2556); //if (Scenes.Editor.MapBuilder.loadedMap != null) //{ // bs.UpdatePosition(); //} // List<List<Object>> luaStuff = new List<List<object>>(); //var ttt = (state["save"] as NLua.LuaFunction).Call()[0].GetType(); (state["save"] as NLua.LuaFunction).Call(); var st = LuaSaveData.getGlobalData("My Collection", "luaStuff"); (state["loadProcess"] as NLua.LuaFunction).Call(); //var dabdab = ((state["getShapeData"] as NLua.LuaFunction).Call(bs)); // NLua.LuaFunction savedFunction = state["e1.Test"] as NLua.LuaFunction; uic = ((state["createUI"] as NLua.LuaFunction).Call()[0] as LuaUICollection).ConvertFromLua(state); goto skip; var luaRect = ShapeAnimation.animFromLuaInfo(((state["generateAnimation"] as NLua.LuaFunction).Call()[0] as LuaShapeAnimationInfo)); var resldo = (state["returnLuaSpecificData"] as NLua.LuaFunction).Call()[0]; NLua.LuaTable lt = (state["returnLuaSpecificData"] as NLua.LuaFunction).Call()[0] as NLua.LuaTable; (state["GenerateSomeStuff"] as NLua.LuaFunction).Call(); ListDataProvider.setLuaData(state); (state["publicStaticCall"] as NLua.LuaFunction).Call(); (state["internalStaticCall"] as NLua.LuaFunction).Call(); state["testObj"] = tc; var ele2 = (state["attempt"] as NLua.LuaFunction).Call()[0]; var returnedData = (state["returnData"] as NLua.LuaFunction).Call()[0]; var oldProvision = state["provision"]; var value2 = state["testObj.i"]; var function = state["MyFunc"] as NLua.LuaFunction; var funcRes = function.Call(state["testObj.i"])[0]; var tableResult = (state["returnTable"] as NLua.LuaFunction).Call()[0]; var bCompare1 = tableResult.GetType() == typeof(NLua.LuaTable); var tableToList = LUAUtilities.LUATableToListUtility(typeof(testClass), tableResult as NLua.LuaTable).Cast <testClass>().ToList(); var tableToListGenericObject = LUAUtilities.LUATableToListUtility(typeof(testClass), tableResult as NLua.LuaTable); var listType = tableToList.GetType(); var listTypeGO = tableToListGenericObject.GetType(); state = new NLua.Lua(); state.LoadCLRPackage(); state.DoFile(ofd.FileName); List <testClass> tcl = new List <testClass>(); tcl.Add(new testClass("")); tcl.Last().i = 25; tcl.Add(new testClass("")); tcl.Last().i = 0; tcl.Add(new testClass("")); tcl.Last().i = 10; foreach (var item in tcl) { (state["setStuff"] as NLua.LuaFunction).Call(item); } tcl = LUAUtilities.LUATableToListUtility(typeof(testClass), (state["doStuff"] as NLua.LuaFunction).Call()[0] as NLua.LuaTable).Cast <testClass>().ToList(); skip : { } bDoTest = false; }