Ejemplo n.º 1
0
 public void AccessObjectProperty()
 {
     using (Lua lua = new Lua())
     {
         TestClass t1 = new TestClass();
         t1.testval = 4;
         lua["netobj"] = t1;
         lua.DoString("var=netobj.testval");
         double var = (double)lua["var"];
         //Console.WriteLine("value from Lua="+var);
         Assert.Equal(4, var);
         lua.DoString("netobj.testval=3");
         Assert.Equal(3, t1.testval);
         //Console.WriteLine("new val (from Lua)="+t1.testval);
     }
 }
Ejemplo n.º 2
0
 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.Equal(num, 3d);
     }
 }
Ejemplo n.º 3
0
        public void TestRemoting()
        {
            using( Lua remoting1 = new Lua( ) )
            using( Lua remoting2 = new Lua( ) )
            {
                remoting1["remote"] = RemoteFunction.Instance;

                LookupTable<string, Lua>.Store( "TestRemoting1", remoting1 );
                LookupTable<string, Lua>.Store( "TestRemoting2", remoting2 );

                remoting1.DoString( LuaScripts.GetScriptString( "TestRemoting1" ) );
                remoting2.DoString( LuaScripts.GetScriptString( "TestRemoting2" ) );

                AssertOutput( remoting2, "Execute", "TestRemoting1: Value 2\nValue 1" );
            }
        }
Ejemplo n.º 4
0
        public void Ensure_That_CLR_Errors_Are_Received( )
        {
            using( Lua err = new Lua( ) )
            {
                err["throwClrException"] = ThrowClrException.Instance;
                err.DoString( LuaScripts.GetScriptString( "TestExecution" ) );

                try
                {
                    ((LuaFunction)err["ExecuteClr"]).Call( );
                    Assert.Fail( "Test CLR Errors: error not received." );
                }
                catch
                {
                    // Assert.Pass
                }
            }
        }
Ejemplo n.º 5
0
 private void CheckInventoryItems()
 {
     foreach (WoWItem item in ObjectManager.GetObjectsOfType <WoWItem>())
     {
         for (int i = 0; i <= _data.GetUpperBound(0); i++)
         {
             if (_data[i, 1] == item.Entry)
             {
                 int cnt = Convert.ToInt32(Lua.GetReturnValues(String.Format("return GetItemCount(\"{0}\")", item.Name), Name + ".lua")[0]);
                 int max = (int)(cnt / _data[i, 0]);
                 for (int j = 0; j < max; j++)
                 {
                     String s = String.Format("UseItemByName(&quot;item:\"{0}\"&quot;)", item.Name);
                     slog("Using {0} we have {1}", item.Name, cnt);
                     Lua.DoString(s);
                     StyxWoW.SleepForLagDuration();
                 }
                 break;
             }
         }
     }
 }
Ejemplo n.º 6
0
                protected override void Run()
                {
                    LuaSystem luaSys = new LuaSystem(MainSession, MainSystem, StdOut, StdIn, StdErr);
                    Lua       l      = luaSys.Lua;

                    try
                    {
                        if (Argv.Count > 1)
                        {
                            NixPath newPath = OpenPath(Argv[1]);
                            string  file    = MainSystem.RootDrive.GetPathTo(newPath.ToString());
                            Debug.Log("File to load: " + newPath.ToString());
                            if (File.Exists(file))
                            {
                                string argStr = "arg={}\n";
                                argStr += "arg[0]=\"" + Argv[1].Replace("\\", "/") + "\"\n";
                                for (int i = 2; i < Argv.Count; i++)
                                {
                                    argStr += "arg[" + (i - 1) + "]=\"" + Argv[i] + "\"\n";
                                }
                                l.DoString(argStr);
                                l.DoFile(newPath.ToString());
                            }
                            else
                            {
                                StdOut.WriteLine("Unable to find file: " + Argv[1]);
                            }
                        }
                        else
                        {
                            // Do stdin stuff
                        }
                    }
                    catch (Exception exp)
                    {
                        StdOut.WriteLine("Exception executing Lua: " + exp.Message);
                    }
                }
Ejemplo n.º 7
0
        static public EsoCharacter ParseLua(string luaTable)
        {
            var LuaClient = new Lua();

            object[] result = null;

            try
            {
                result = LuaClient.DoString(luaTable);
            }

            catch (NLua.Exceptions.LuaException error)
            {
                var luaErrorResponse = MessageBox.Show($"Something went wrong while reading data from ESO: {error.Message}", "Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2);

                if (luaErrorResponse == DialogResult.Retry)
                {
                    ParseLua(luaTable);
                }
                else if (luaErrorResponse == DialogResult.Abort)
                {
                    Application.Exit();
                }
            }

            LuaTable rootTable    = LuaClient.GetTable($"{Main.ADDON_NAME}_SavedVars");
            LuaTable defaultTable = (LuaTable)rootTable["Default"];

            Dictionary <object, LuaTable> Accounts = new Dictionary <object, LuaTable>();

            foreach (object key in defaultTable.Keys)
            {
                LuaTable value = (LuaTable)defaultTable[key];
                Accounts.Add(key, value);
            }

            return(new EsoCharacter((LuaTable)Accounts.Values.First()["$AccountWide"]));
        }
Ejemplo n.º 8
0
        public static bool On_PetAttack()
        {
            bool   retval;
            string fnname = "FTWCore.On_PetAttack";

            MyTimer.Start(fnname);
            using (StyxWoW.Memory.AcquireFrame())
            {
                if (!(StyxWoW.Me.GotAlivePet))
                {
                    FTWLogger.log(Color.Red, "Don't have alive pet");
                    retval = false;
                }
                else
                {
                    WoWUnit pet = StyxWoW.Me.Pet;
                    if (pet.CurrentTargetGuid == StyxWoW.Me.CurrentTargetGuid)
                    {
                        retval = false;
                    }
                    else
                    {
                        FTWLogger.log("    Siccing pet on {0} health {1:0} dist {2:0.0}", StyxWoW.Me.CurrentTarget.SafeName(), StyxWoW.Me.CurrentTarget.HealthPercent, StyxWoW.Me.CurrentTarget.DistanceCalc());
                        foreach (WoWPetSpell sp in StyxWoW.Me.PetSpells)
                        {
                            if (sp.Action.ToString() == "Attack")
                            {
                                Lua.DoString("CastPetAction({0})", sp.ActionBarIndex + 1);
                                break;
                            }
                        }
                        retval = false;
                    }
                }
            }
            MyTimer.Stop(fnname);
            return(retval);
        }
Ejemplo n.º 9
0
        private void HandleTalentPointsChanged(object sender, LuaEventArgs args)
        {
            if (!HasLearnedMajorTree)
            {
                SelectMajorTalentTree(_talentBuild.Specialization);
            }

            var learned = BuildLearnedTalentDictionary();
            var wanted  = GetCurrentSpecTalentPlacements();

            int numAvailable = Lua.GetReturnVal <int>("return GetUnspentTalentPoints()", 0);

            foreach (var tp in wanted)
            {
                if (numAvailable == 0)
                {
                    continue;
                }

                var lt = learned.FirstOrDefault(t => (t.Name == tp.Name) || (t.Index == tp.Index && t.Tab == tp.Tab));

                int numLearned = 0;

                if (lt != null)
                {
                    numLearned = lt.Count;
                }

                while (numAvailable != 0 && numLearned < tp.Count)
                {
                    LearnTalent(tp.Tab, tp.Index);
                    numLearned++;
                    numAvailable--;
                }
            }

            Lua.DoString("LearnPreviewTalents()");
        }
Ejemplo n.º 10
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =
                                 new PrioritySelector(
                                     new Decorator(
                                         ret => wp.Distance(ObjectManager.Me.Location) > 5,
                                         new Sequence(
                                             new Action(ret => TreeRoot.StatusText = "Moving to location"),
                                             new Action(ret => Navigator.MoveTo(wp)))),
                                     new Decorator(
                                         ret => !ObjectManager.Me.HasAura("Vault Cracking Toolset"),
                                         new Sequence(
                                             new Action(ret => q14122bank[0].Interact()),
                                             new Action(ret => StyxWoW.SleepForLagDuration())
                                             )),

                                     new Decorator(
                                         ret => !IsAttached,
                                         new Sequence(
                                             new Action(ret => Lua.Events.AttachEvent("CHAT_MSG_RAID_BOSS_WHISPER", q14122msg)),
                                             new Action(ret => IsAttached = true))),
                                     new Decorator(
                                         ret => StyxWoW.Me.QuestLog.GetQuestById(14122).IsCompleted,
                                         new PrioritySelector(
                                             new Decorator(
                                                 ret => IsAttached,
                                                 new Sequence(
                                                     new Action(ret => Styx.Helpers.Logging.Write("Detaching")),
                                                     new Action(ret => Lua.Events.DetachEvent("CHAT_MSG_RAID_BOSS_WHISPER", q14122msg)),
                                                     new Action(ret => IsBehaviorDone = true)
                                                     )))),
                                     new Decorator(
                                         ret => StyxWoW.Me.QuestLog.GetQuestById(14122).IsCompleted&& ObjectManager.Me.HasAura("Vault Cracking Toolset"),
                                         new Sequence(
                                             new Action(ret => Lua.DoString("VehicleExit()"))
                                             ))
                                     )));
        }
 private Composite CreateBehavior_CombatMain()
 {
     return(_root ??
            (_root =
                 new Decorator(
                     ret => !_isBehaviorDone,
                     new PrioritySelector(
                         // Leave vehicle if time is pass.
                         new Decorator(ret => _doingQuestTimer.ElapsedMilliseconds >= 180000,
                                       new Sequence(
                                           new Action(ret => _doingQuestTimer.Restart()),
                                           new Action(ret => Lua.DoString("VehicleExit()")),
                                           new Sleep(4000)
                                           )),
                         // Get in a vehicle if not in one.
                         new Decorator(ret => !Query.IsInVehicle(),
                                       new Sequence(
                                           new DecoratorContinue(ret => Catapult.Count == 0,
                                                                 new Sequence(
                                                                     new Action(ret => Navigator.MoveTo(_catapultLoc)),
                                                                     new Sleep(1000)
                                                                     )),
                                           new DecoratorContinue(ret => Catapult.Count > 0 && Catapult[0].Location.Distance(Me.Location) > 5,
                                                                 new Sequence(
                                                                     new Action(ret => Navigator.MoveTo(Catapult[0].Location)),
                                                                     new Sleep(1000)
                                                                     )),
                                           new DecoratorContinue(ret => Catapult.Count > 0 && Catapult[0].Location.Distance(Me.Location) <= 5,
                                                                 new Sequence(
                                                                     new Action(ret => WoWMovement.MoveStop()),
                                                                     new Action(ret => Catapult[0].Interact()),
                                                                     new Sleep(1000)
                                                                     ))
                                           )),
                         CreateBehavior_CheckQuestCompletion(),
                         CreateBehavior_ShootCatapult()
                         ))));
 }
Ejemplo n.º 12
0
        private void CheckInventoryItems()
        {
            foreach (WoWItem item in StyxWoW.Me.BagItems)
            {
                for (int i = 0; i <= _data.GetUpperBound(0); i++)
                {
                    if (_data[i, 1] == item.Entry)
                    {
                        while (IteminBag(item.Entry))
                        {
                            String s = String.Format("UseItemByName(\"{0}\")", item.Name);
                            Lua.DoString(s);
                            StyxWoW.SleepForLagDuration();

                            if (LootFrame.Instance.IsVisible)
                            {
                                Lua.DoString("for i=1,GetNumLootItems() do ConfirmLootSlot(i) LootSlot(i) end");
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public static void Main(string[] args)
        {
            Lua lua = new Lua();
            lua.DynamicContext.print = (LuaFunction)print;
            lua.DynamicContext.read = (LuaFunction)read;

            while (true)
            {
                string line = Console.ReadLine();
                try
                {
                    lua.DoString(line);
                }
                catch (LuaException ex)
                {
                    for (int i = 0; i < ex.col - 1; i++)
                        Console.Write(" ");

                    Console.WriteLine("^");
                    Console.WriteLine(ex.message);
                }
            }
        }
Ejemplo n.º 14
0
        public Plugin LoadPlugin(string rootFolderName)
        {
            using (Lua lua = new Lua()) {
                lua.LoadCLRPackage();
                lua.DoString(@"package.path = './plugins/" + rootFolderName + "/?.lua'");
                lua.DoFile(rootFolderName + "/metadata.lua");

                string root = lua["plugin.root"] as string;

                lua.DoFile(rootFolderName + "/init.lua");

                return(new Plugin()
                {
                    PluginName = lua["plugin.name"] as string,
                    PluginAuthor = lua["plugin.author"] as string,
                    PluginPrefix = lua["plugin.prefix"] as string,
                    PluginVersion = lua["plugin.version"] as string,
                    ServerInit = lua[root + ".OnServerStart"] as LuaFunction,
                    ServerStop = lua[root + ".OnServerStop"] as LuaFunction,
                    OnConnectRequest = lua[root + ".OnConnectRequest"] as LuaFunction,
                });
            }
        }
Ejemplo n.º 15
0
        public bool UseAbility()
        {
            if (!Query.IsVehicleActionBarShowing())
            {
                QBCLog.Warning("Attempted to use {0} while not in Vehicle!", Name);
                return(false);
            }

            if (IsAbilityReady())
            {
                Lua.DoString(_luaCommand_UseAbility);
                ++AbilityUseCount;

                if (LogAbilityUse)
                {
                    QBCLog.DeveloperInfo("{0} ability used (count: {1})", Name, AbilityUseCount);
                }

                return(true);
            }

            return(false);
        }
        private void OnRun()
        {
            string script = codeView.Text;

            try {
                if (error)
                {
                    outputView.TextColor = UIColor.DarkTextColor;
                    outputView.Text      = string.Empty;
                    error = false;
                }

                lua.DoString(script);
            } catch (Exception e) {
                outputView.TextColor = UIColor.Red;
                outputView.Text      = "ERROR: " + e;
                if (e.InnerException != null)
                {
                    outputView.Text += "\n" + e.InnerException;
                }
                error = true;
            }
        }
Ejemplo n.º 17
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =
                                 new PrioritySelector(

                                     new Decorator(ret => _isBehaviorDone,
                                                   new ActionAlwaysSucceed()),

                                     new Sequence(
                                         new Action(delegate
            {
                TreeRoot.StatusText = "Ejecting from vehicle";
                Lua.DoString("VehicleExit()");
            }),
                                         new WaitContinue(Delay_WowClientLagTime, ret => false, new ActionAlwaysSucceed()),
                                         new Action(delegate
            {
                TreeRoot.StatusText = "Vehicle eject complete";
                _isBehaviorDone = true;
            })
                                         )
                                     )));
        }
Ejemplo n.º 18
0
        private void GuildInvite(object sender, LuaEventArgs e)
        {
            // Our Var's

            string GuildName;
            int    GuildLevel;

            GuildName  = e.Args[1].ToString();
            GuildLevel = Convert.ToInt32(e.Args[2]);


            if (GuildLevel >= LevelToJoin)
            {
                Write("Accepting - Guild Name: {0}  Guild Level: {1}", GuildName, GuildLevel);
                Lua.DoString("AcceptGuild()");
            }
            else
            {
                Write("Declining - Guild Name: {0}  Guild Level: {1}", GuildName, GuildLevel);
                Lua.DoString("DeclineGuild()");
            }
            Lua.DoString("StaticPopup_Hide(\"GUILD_INVITE_REQUEST\")");
        }
Ejemplo n.º 19
0
        public void RunLoop()
        {
            this._isRuning = true;

            string input;

            while (_isRuning)
            {
                try
                {
                    Console.WriteLine("> ");

                    input = Console.ReadLine();
                    Console.WriteLine();

                    LuaVM.DoString(input);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Ejemplo n.º 20
0
 public static void Prospectingspell()
 {
     foreach (WoWItem item in ObjectManager.Me.BagItems)
     {
         if (OreList.Contains(item.Entry))
         {
             WoWMovement.MoveStop();
             Thread.Sleep(250);
             while (item.StackCount >= 5 && item.BagSlot != -1)
             {
                 SpellManager.Cast(31252);
                 Logging.Write(Color.Cyan, "[Prospecting]:Using " + item.Name + " i have {0}", NumOfItemsInBag(item.Entry));
                 Lua.DoString(string.Format("UseContainerItem({0}, {1})", item.BagIndex + 1, item.BagSlot + 1));
                 Thread.Sleep(4500);
             }
             if (ObjectManager.Me.FreeNormalBagSlots <= 2)
             {
                 Logging.Write(Color.Red, "Stopping Because Free Bagspace");
                 break;
             }
         }
     }
 }
        public void LoadScript(string scriptString, string scriptName = "User Code")
        {
            //Remove old hooks so they aren't counted
            if (ScriptStandard != null)
            {
                ScriptStandard.Scrub(Lua, scriptContainer);
            }

            scriptContainer.ResetHooks();

            Lua.DoString(scriptString, null, scriptName);

            if (ScriptStandard != null)
            {
                List <string> errors = new List <string>();
                bool          res    = ScriptStandard.ApplyStandard(Lua, scriptContainer, errors);
                if (!res)
                {
                    //Todo: new type of exception with info
                    throw new Exception($"Script Standard was not met! Standards Not Met: [{string.Join(", ", errors)}]");
                }
            }
        }
Ejemplo n.º 22
0
        public override void Death()
        {
            if (NeedDeath)
            {
                if (SettingsManager.Instance.ReleaseSpiritOnDeathEnabled)
                {
                    if (!DeathTimer.IsRunning)
                    {
                        DeathTimer.Start();
                    }
                    if (DeathTimer.ElapsedMilliseconds >= SettingsManager.Instance.ReleaseSpiritOnDeathIntervalInMs)
                    {
                        Log.Gui(string.Format("I have died. Corpse released after {0} ms",
                                              DeathTimer.ElapsedMilliseconds));

                        DeathTimer.Reset();
                        Lua.DoString("RunMacroText(\"/script RepopMe()\")");
                    }
                }
            }

            base.Death();
        }
        public static void CombatLogEventHander(object sender, LuaEventArgs args)
        {
            foreach (object arg in args.Args)
            {
                if (arg is String)
                {
                    var s = (string)arg;

                    //if (s.Contains("Crab")) Utils.Log("CRAB-EH!",Color.Red);

                    if (s.Contains("EVADE"))
                    {
                        if (Me.GotTarget)
                        {
                            Logging.Write("My target is Evade bugged, blacking " + CT.Name, Color.Red);
                            Target.BlackList(3600);
                            Lua.DoString("StopAttack() PetStopAttack() PetFollow()");
                            StyxWoW.Me.ClearTarget();
                        }
                    }
                }
            }
        }
Ejemplo n.º 24
0
 protected override Composite CreateBehavior()
 {
     return(_root ??
            (_root = new PrioritySelector(
                 new Action(c =>
     {
         if (Slot == (int)InventorySlot.None)
         {
             Lua.DoString("EquipItemByName (\"" + ItemId + "\")");
         }
         else
         {
             WoWItem item = ObjectManager.Me.BagItems.FirstOrDefault(i => i.Entry == ItemId);
             if (item != null)
             {
                 Lua.DoString("PickupContainerItem({0},{1}) EquipCursorItem({2})",
                              item.BagIndex + 1, item.BagSlot + 1, Slot);
             }
         }
         _isBehaviorDone = true;
     })
                 )));
 }
Ejemplo n.º 25
0
        public static void Run()
        {
            if (isLoaded)
            {
                try
                {
                    script.DoString(code);
#if NLUA
                    _OnStart    = script.GetFunction("OnStart");
                    _OnUpdate   = script.GetFunction("OnUpdate");
                    _OnClose    = script.GetFunction("OnClose");
                    _OnGui      = script.GetFunction("OnGui");
                    _OnScanline = script.GetFunction("OnScanline");
#endif
                    wasExecuted = true;
                }
                catch (NLua.Exceptions.LuaException ex)
                {
                    uRetroConsole.Show();
                    uRetroConsole.PrintError("ERROR: " + ex);
                }
            }
        }
Ejemplo n.º 26
0
        public static Composite CancelMyAura(string name, CanRunDecoratorDelegate cond)
        {
            name = LocalizeSpellName(name);
            var macro = String.Format("/cancelaura {0}", name);

            return(new Decorator(
                       delegate(object a)
            {
                if (name.Length == 0)
                {
                    return false;
                }

                if (!cond(a))
                {
                    return false;
                }

                return true;
            },
                       new Sequence(
                           new Action(a => Lua.DoString("RunMacroText(\"" + RealLuaEscape(macro) + "\")")))));
        }
Ejemplo n.º 27
0
        public static async Task <bool> DeathBehavor()
        {
            if (Me.IsDead)
            {
                L.infoLog(DateTime.Now.ToString("mm:ss:ffffff") + " RepopMe()", Core.Helpers.Common.InfoColor);
                Lua.DoString("RepopMe()");
            }

            if (Me.IsGhost)
            {
                if (Battlegrounds.IsInsideBattleground || Me.CurrentMap.Name == "Ashran")
                {
                    L.infoLog(DateTime.Now.ToString("mm:ss:ffffff") + " Waiting for spirit rez", Core.Helpers.Common.InfoColor);
                    await Coroutine.Sleep(1500);
                }
                else
                {
                    L.infoLog(DateTime.Now.ToString("mm:ss:ffffff") + " Move to corpse", Core.Helpers.Common.InfoColor);
                    await CommonCoroutines.MoveTo(Me.CorpsePoint);
                }
            }
            return(false);
        }
        private static bool IsQuestCompleted(uint ID)
        {
            //to make sure every header is expanded in quest log
            Lua.DoString("ExpandQuestHeader(0)");
            //number of values in quest log (includes headers like "Durator")
            int QuestCount = Lua.GetReturnVal <int>("return select(1, GetNumQuestLogEntries())", 0);

            for (int i = 1; i <= QuestCount; i++)
            {
                List <string> QuestInfo = Lua.LuaGetReturnValue("return GetQuestLogTitle(" + i + ")", "raphus.lua");

                //pass if the index isHeader or isCollapsed
                if (QuestInfo[4] == "1" || QuestInfo[5] == "1")
                {
                    continue;
                }

                string QuestStatus = null;
                if (QuestInfo[6] == "1")
                {
                    QuestStatus = "completed";
                }
                else if (QuestInfo[6] == "-1")
                {
                    QuestStatus = "failed";
                }
                else
                {
                    QuestStatus = "in progress";
                }
                if (QuestInfo[8] == Convert.ToString(ID) && QuestStatus == "completed")
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 29
0
        public void OnLoad()
        {
            Enabled = true;

            _registeredEvents.Clear();
            _registeredCommands.Clear();

            Properties = new PluginProperties(Path.GetFileName(PluginFile), PluginManager.PluginDirectoryPath);
            Properties.Load();

            _lua = new Lua();
            _lua.LoadCLRPackage();

            _lua["properties"] = Properties;
            _lua["plugindir"]  = PluginManager.PluginDirectoryPath;

            _lua.DoString("package.path = package.path .. \";plugins/?.lua\"");

            RegisterTypes();
            RegisterFunctions();

            _lua.DoFile(PluginFile);

            LuaFunction onLoad = _lua.GetFunction("onLoad");

            if (onLoad != null)
            {
                try
                {
                    onLoad.Call();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Plugin {0} caused error: {1}", Path.GetFileName(PluginFile), ex.Message);
                }
            }
        }
Ejemplo n.º 30
0
 public static void Clothspell()
 {
     foreach (WoWItem item in ObjectManager.Me.BagItems)
     {
         if (_itemlist7.Contains(item.Entry) && item.StackCount >= 5)
         {
             WoWMovement.MoveStop();
             Thread.Sleep(100);
             while (NumOfItemsInBag(53010) >= 5)
             {
                 SpellManager.Cast(74964);
                 Thread.Sleep(250);
                 Logging.Write(Color.Red, "[Cloth]:Using " + item.Name + "");
                 Lua.DoString(string.Format("UseContainerItem({0}, {1})", item.BagIndex + 1, item.BagSlot + 1));
                 Thread.Sleep(1000);
                 if (ObjectManager.Me.FreeBagSlots <= 3)
                 {
                     Logging.Write(Color.Red, "Stopping Because Free Bagspace");
                     break;
                 }
             }
             while (NumOfItemsInBag(33470) >= 5)
             {
                 SpellManager.Cast(55899);
                 Thread.Sleep(250);
                 Logging.Write(Color.Red, "[Cloth]:Using " + item.Name + "");
                 Lua.DoString(string.Format("UseContainerItem({0}, {1})", item.BagIndex + 1, item.BagSlot + 1));
                 Thread.Sleep(1000);
                 if (ObjectManager.Me.FreeBagSlots <= 3)
                 {
                     Logging.Write(Color.Red, "Stopping Because Free Bagspace");
                     break;
                 }
             }
         }
     }
 }
Ejemplo n.º 31
0
 /// <summary>
 /// Fly to a Helperpoint for a special Unit
 /// </summary>
 static public bool MoveTo(WoWPoint Helperpoint, WoWUnit o, Int64 Distance, bool ForceGround)
 {
     Logging.Write(Colors.MediumPurple, "Rarekiller: Move to Helperpoint for {0}", o.Name);
     while (Me.Location.Distance(Helperpoint) > Distance)
     {
         if (ForceGround && Me.IsSwimming)
         {
             WoWMovement.ClickToMove(Helperpoint);
         }
         else if (ForceGround)
         {
             Navigator.MoveTo(Helperpoint);
         }
         else
         {
             Flightor.MoveTo(Helperpoint);
         }
         Thread.Sleep(100);
         if (Rarekiller.ToonInvalidCombat)
         {
             return(false);
         }
         if (o.TaggedByOther && !Rarekiller.TaggedMobsList.ContainsKey(Convert.ToInt32(o.Entry)))
         {
             Logging.Write(Colors.MediumPurple, "Rarekiller: Unit {0} is tagged by another Player", o.Name);
             Blacklist.Add(Me.CurrentTarget.Guid, Rarekiller.Settings.Flags, TimeSpan.FromSeconds(Rarekiller.Settings.Blacklist5));
             Logging.WriteDiagnostic(Colors.MediumPurple, "Rarekiller: Blacklist Unit for 5 Minutes.");
             if (Rarekiller.Settings.LUAoutput)
             {
                 Lua.DoString("print('NPCScan: NPC {0} is tagged')", o.Name);
             }
             WoWMovement.MoveStop();
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 32
0
        public static void Inkvendor()
        {
            List <WoWUnit> Merchantlist = ObjectManager.GetObjectsOfType <WoWUnit>();

            while (Me.Location != Movetovendink && NumOfItemsInBag(61978) > 10)
            {
                Logging.Write("Moving to Ink Vendor");
                Navigator.MoveTo(Movetovendink);
                if (Me.Location.Distance(Movetovendink) < 5)
                {
                    Logging.Write("breaking loop");
                    break;
                }
            }

            foreach (WoWUnit u in Merchantlist)
            {
                if (!Me.Combat && NumOfItemsInBag(61978) >= 10)
                {
                    while (u.Name == "Sarana Damir" && u.Distance <= 5)
                    {
                        u.Target();
                        WoWMovement.MoveStop();
                        u.Interact(u.Name == "Sarana Damir");
                        Thread.Sleep(250);
                        int i = 11;
                        Logging.Write("Trading Inks");
                        Lua.DoString("BuyMerchantItem(\"" + i + "\",1)");
                        Thread.Sleep(100);
                        if (NumOfItemsInBag(61978) < 10)
                        {
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 33
0
 public override void Pulse()
 {
     if (!_init)
     {
         base.OnEnable();
         Lua.DoString("SetCVar('AutoLootDefault','1')");
         Lua.Events.AttachEvent("LOOT_CLOSED", LootFinished);
         Lua.Events.AttachEvent("MAIL_CLOSED", MailboxFinished);
         Logging.Write(LogLevel.Normal, Colors.DarkRed, "StrongBoxOpener ready for use...");
         _init = true;
     }
     if (_init)
     {
         if (StyxWoW.Me.IsActuallyInCombat || StyxWoW.Me.IsDead || StyxWoW.Me.IsGhost)
         {
             return;
         }
     }
     if ()
     {
         foreach (WoWItem item in ObjectManager.GetObjectsOfType <WoWItem>())              // iterate over every item
         {
             if (item != null && item.BagSlot != -1 && StyxWoW.Me.FreeNormalBagSlots >= 2) // check if item exists and is in bag and we have space
             {
                 if (_itemUseOnOne.Contains(item.Entry))                                   // stacks of 1
                 {
                     if (item.StackCount >= 1)
                     {
                         this.useItem(item);
                     }
                 }
             }
         }
         InventoryCheck = false;
         StyxWoW.SleepForLagDuration();
     }
 }
Ejemplo n.º 34
0
        public static string RunLuaScript(string scriptBody)
        {
            string scriptCode = "function GetNext()\n" + scriptBody + "\nend";
            Lua    state      = new Lua();

            // Add the CoptLib date functions
            state["Today"] = DateTime.Today.Ticks;
            //state["NextCovenantThursday"] = (Func<LocalDate>)CopticDateHelper.GetNextCovenantThursday;
            //state["NextFeastResurrection"] = (Func<LocalDate>)CopticDateHelper.GetNextFeastResurrection;
            //state["NextGoodFriday"] = (Func<LocalDate>)CopticDateHelper.GetNextGoodFriday;
            //state["NextHosannaSunday"] = (Func<LocalDate>)CopticDateHelper.GetNextHosannaSunday;
            //state["NextLazarusSaturday"] = (Func<LocalDate>)CopticDateHelper.GetNextLazarusSaturday;
            //state["NextNativity"] = (Func<LocalDate>)CopticDateHelper.GetNextNativity;
            //state["NextNativityFast"] = (Func<LocalDate>)CopticDateHelper.GetNextNativityFast;
            //state["NextNativitySunday"] = (Func<LocalDate>)CopticDateHelper.GetNextNativitySunday;
            //state["NextPascha"] = (Func<LocalDate>)CopticDateHelper.GetNextPascha;
            //state["NextSpringEquinox"] = (Func<LocalDate>)CopticDateHelper.GetNextSpringEquinox;

            try
            {
                state.DoString(scriptCode);
                var script = state["GetNext"] as LuaFunction;

                if (script?.Call()[0] is string res)
                {
                    return(res);
                }
                else
                {
                    throw new InvalidCastException("Invalid return type");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Ejemplo n.º 35
0
 private void SplitItemStack()
 {
     Lua.DoString(
         string.Format(
             "local amount = {0}; ", _Rest) +
         string.Format(
             "local item = {0}; ", ItemID) +
         "local ItemBagNr = 0; " +
         "local ItemSlotNr = 1; " +
         "local EmptyBagNr = 0; " +
         "local EmptySlotNr = 1; " +
         "SplitDone = 0; " +
         "for b=0,4 do " +
         "for s=1,GetContainerNumSlots(b) do " +
         "if ((GetContainerItemID(b,s) == item) and (select(3, GetContainerItemInfo(b,s)) == nil)) then " +
         "ItemBagNr = b; " +
         "ItemSlotNr = s; " +
         "end; " +
         "end; " +
         "end; " +
         "for b=0,4 do " +
         "for s=1,GetContainerNumSlots(b) do " +
         "if GetContainerItemID(b,s) == nil then " +
         "EmptyBagNr = b; " +
         "EmptySlotNr = s; " +
         "end; " +
         "end; " +
         "end; " +
         "ClearCursor(); " +
         "SplitContainerItem(ItemBagNr,ItemSlotNr,amount); " +
         "if CursorHasItem() then " +
         "PickupContainerItem(EmptyBagNr,EmptySlotNr); " +
         "ClearCursor(); " +
         "SplitDone = 1; " +
         "end;"
         );
 }
Ejemplo n.º 36
0
 public void CreateNetObjectOverloadedCons()
 {
     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('str')");
         object[] res = lua.DoString("return test");
         TestClass test = (TestClass)res[0];
         //Console.WriteLine("returned: "+test.getStrVal());
         Assert.Equal("str", test.getStrVal());
     }
 }
Ejemplo n.º 37
0
 public void DoString()
 {
     using (Lua lua = new Lua())
     {
         object[] res = lua.DoString("a=2\nreturn a,3");
         //Console.WriteLine("a="+res[0]+", b="+res[1]);
         Assert.Equal(res[0], 2d);
         Assert.Equal(res[1], 3d);
     }
 }
Ejemplo n.º 38
0
 public void GetTableStringField2()
 {
     using (Lua lua = new Lua())
     {
         lua.DoString("a={b={c=\"test\"}}");
         LuaTable tab = lua.GetTable("a");
         string str = (string)tab["b.c"];
         //Console.WriteLine("a.b.c="+str);
         Assert.Equal(str, "test");
     }
 }
Ejemplo n.º 39
0
        /*
         * Sample test script that shows some of the capabilities of
         * LuaInterface
         */
        public static void Main()
        {
            Console.WriteLine("Starting interpreter...");
            var l = new Lua();

            // Pause so we can connect with the debugger
            // Thread.Sleep(30000);
            Console.WriteLine("Reading test.lua file...");
            l.DoFile("test.lua");
            double width = l.GetNumber("width");
            double height = l.GetNumber("height");
            string message = l.GetString("message");
            double color_r = l.GetNumber("color.r");
            double color_g = l.GetNumber("color.g");
            double color_b = l.GetNumber("color.b");
            Console.WriteLine("Printing values of global variables width, height and message...");
            Console.WriteLine("width: " + width);
            Console.WriteLine("height: " + height);
            Console.WriteLine("message: " + message);
            Console.WriteLine("Printing values of the 'color' table's fields...");
            Console.WriteLine("color.r: " + color_r);
            Console.WriteLine("color.g: " + color_g);
            Console.WriteLine("color.b: " + color_b);
            width = 150;
            Console.WriteLine("Changing width's value and calling Lua function print to show it...");
            l["width"] = width;
            l.GetFunction("print").Call(width);
            message = "LuaNet Interface Test";
            Console.WriteLine("Changing message's value and calling Lua function print to show it...");
            l["message"] = message;
            l.GetFunction("print").Call(message);
            color_r = 30;
            color_g = 10;
            color_b = 200;
            Console.WriteLine("Changing color's fields' values and calling Lua function print to show it...");
            l["color.r"] = color_r;
            l["color.g"] = color_g;
            l["color.b"] = color_b;
            l.DoString("print(color.r,color.g,color.b)");
            Console.WriteLine("Printing values of the tree table's fields...");
            double leaf1 = l.GetNumber("tree.branch1.leaf1");
            string leaf2 = l.GetString("tree.branch1.leaf2");
            string leaf3 = l.GetString("tree.leaf3");
            Console.WriteLine("leaf1: " + leaf1);
            Console.WriteLine("leaf2: " + leaf2);
            Console.WriteLine("leaf3: " + leaf3);
            leaf1 = 30; leaf2 = "new leaf2";
            Console.WriteLine("Changing tree's fields' values and calling Lua function print to show it...");
            l["tree.branch1.leaf1"] = leaf1; l["tree.branch1.leaf2"] = leaf2;
            l.DoString("print(tree.branch1.leaf1,tree.branch1.leaf2)");
            Console.WriteLine("Returning values from Lua with 'return'...");
            object[] vals = l.DoString("return 2,3");
            Console.WriteLine("Returned: " + vals[0] + " and " + vals[1]);
            Console.WriteLine("Calling a Lua function that returns multiple values...");
            object[] vals1 = l.GetFunction("func").Call(2, 3);
            Console.WriteLine("Returned: " + vals1[0] + " and " + vals1[1]);
            Console.WriteLine("Creating a table and filling it from C#...");
            l.NewTable("tab");
            l.NewTable("tab.tab");
            l["tab.a"] = "a!";
            l["tab.b"] = 5.5;
            l["tab.tab.c"] = 6.5;
            l.DoString("print(tab.a,tab.b,tab.tab.c)");
            Console.WriteLine("Setting a table as another table's field...");
            l["tab.a"] = l["tab.tab"];
            l.DoString("print(tab.a.c)");
            Console.WriteLine("Registering a C# static method and calling it from Lua...");

            // Pause so we can connect with the debugger
            // Thread.Sleep(30000);
            l.RegisterFunction("func1", null, typeof(TestLuaInterface).GetMethod("func"));
            vals1 = l.GetFunction("func1").Call(2, 3);
            Console.WriteLine("Returned: " + vals1[0]);
            TestLuaInterface obj = new TestLuaInterface();
            Console.WriteLine("Registering a C# instance method and calling it from Lua...");
            l.RegisterFunction("func2", obj, typeof(TestLuaInterface).GetMethod("funcInstance"));
            vals1 = l.GetFunction("func2").Call(2, 3);
            Console.WriteLine("Returned: " + vals1[0]);

            Console.WriteLine("Testing throwing an exception...");
            obj.ThrowUncaughtException();

            Console.WriteLine("Testing catching an exception...");
            obj.ThrowException();

            Console.WriteLine("Testing inheriting a method from Lua...");
            obj.LuaTableInheritedMethod();

            Console.WriteLine("Testing overriding a C# method with Lua...");
            obj.LuaTableOverridedMethod();

            Console.WriteLine("Stress test RegisterFunction (based on a reported bug)..");
            obj.RegisterFunctionStressTest();

            Console.WriteLine("Test structures...");
            obj.TestStructs();

            Console.WriteLine("Test Nullable types...");
            obj.TestNullable();

            Console.WriteLine("Test functions...");
            obj.TestFunctions();

            Console.WriteLine("Test method overloads...");
            obj.TestMethodOverloads();

            Console.WriteLine("Test accessing private method...");
            obj.TestPrivateMethod();

            Console.WriteLine("Test event exceptions...");
            obj.TestEventException();

            Console.WriteLine("Test chunk overload exception...");
            obj.TestExceptionWithChunkOverload();

            Console.WriteLine("Test generics...");
            obj.TestGenerics();

            Console.WriteLine("Test threading...");
            obj.TestThreading();

            Console.WriteLine("Test memory leakage...");
            obj.TestDispose();

            Console.WriteLine("Press enter to exit.");
            Console.ReadLine();
        }
Ejemplo n.º 40
0
 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);
     }
 }
Ejemplo n.º 41
0
 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);
     }
 }
Ejemplo n.º 42
0
 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);
     }
 }
Ejemplo n.º 43
0
 public void GetStringInTable()
 {
     using (Lua lua = new Lua())
     {
         lua.DoString("a={b={c=\"test\"}}");
         string str = lua.GetString("a.b.c");
         //Console.WriteLine("a.b.c="+str);
         Assert.Equal(str, "test");
     }
 }
Ejemplo n.º 44
0
 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);
     }
 }
Ejemplo n.º 45
0
        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);
            }
        }
Ejemplo n.º 46
0
 public void CallGlobalFunctionOneReturn()
 {
     using (Lua lua = new Lua())
     {
         lua.DoString("function f(x)\nreturn x+2\nend");
         object[] ret = lua.GetFunction("f").Call(3);
         //Console.WriteLine("ret="+ret[0]);
         Assert.Equal(1, ret.Length);
         Assert.Equal(5, (double)ret[0]);
     }
 }
Ejemplo n.º 47
0
 public void CreateNetObjectNoArgsCons()
 {
     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("test:setVal(3)");
         object[] res = lua.DoString("return test");
         TestClass test = (TestClass)res[0];
         //Console.WriteLine("returned: "+test.testval);
         Assert.Equal(3, test.testval);
     }
 }
Ejemplo n.º 48
0
 public void CallTableFunctionTwoReturns()
 {
     using (Lua lua = new Lua())
     {
         lua.DoString("a={}\nfunction a.f(x,y)\nreturn x,x+y\nend");
         object[] ret = lua.GetFunction("a.f").Call(3, 2);
         //Console.WriteLine("ret="+ret[0]+","+ret[1]);
         Assert.Equal(2, ret.Length);
         Assert.Equal(3, (double)ret[0]);
         Assert.Equal(5, (double)ret[1]);
     }
 }
Ejemplo n.º 49
0
 public void GetTableNumericField2()
 {
     using (Lua lua = new Lua())
     {
         lua.DoString("a={b={c=2}}");
         LuaTable tab = lua.GetTable("a");
         double num = (double)tab["b.c"];
         //Console.WriteLine("a.b.c="+num);
         Assert.Equal(num, 2d);
     }
 }
Ejemplo n.º 50
0
 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);
     }
 }
Ejemplo n.º 51
0
 public void CreateArray()
 {
     using (Lua lua = new Lua())
     {
         lua.DoString("luanet.load_assembly(\"LuaInterface.Test\")");
         lua.DoString("TestClass=luanet.import_type(\"LuaInterface.Test.Mock.TestClass\")");
         lua.DoString("arr=TestClass[3]");
         lua.DoString("for i=0,2 do arr[i]=TestClass(i+1) end");
         TestClass[] arr = (TestClass[])lua["arr"];
         Assert.Equal(arr[1].testval, 2);
     }
 }
Ejemplo n.º 52
0
 public void GetStaticMethodBySignature()
 {
     using (Lua lua = new Lua())
     {
         lua.DoString("luanet.load_assembly('mscorlib')");
         lua.DoString("luanet.load_assembly('LuaInterface.Test')");
         lua.DoString("TestClass=luanet.import_type('LuaInterface.Test.Mock.TestClass')");
         lua.DoString("make_method=luanet.get_method_bysig(TestClass,'makeFromString','System.String')");
         lua.DoString("test=make_method('test')");
         TestClass test = (TestClass)lua["test"];
         Assert.Equal("test", test.getStrVal());
         //Console.WriteLine("interface returned: "+test.getStrVal());
     }
 }
Ejemplo n.º 53
0
 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);
     }
 }
Ejemplo n.º 54
0
 public void GetGlobalString()
 {
     using (Lua lua = new Lua())
     {
         lua.DoString("a=\"test\"");
         string str = lua.GetString("a");
         //Console.WriteLine("a="+str);
         Assert.Equal(str, "test");
     }
 }
Ejemplo n.º 55
0
 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);
     }
 }
Ejemplo n.º 56
0
 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);
     }
 }
Ejemplo n.º 57
0
        private void _Calc(Lua lua, int i)
        {
            lua.DoString(
                     "sqrt = math.sqrt;" +
                     "sqr = function(x) return math.pow(x,2); end;" +
                     "log = math.log;" +
                     "log10 = math.log10;" +
                     "exp = math.exp;" +
                     "sin = math.sin;" +
                     "cos = math.cos;" +
                     "tan = math.tan;" +
                     "abs = math.abs;"
                     );

            lua.DoString("function calcVP(a,b) return a+b end");
            LuaFunction lf = lua.GetFunction("calcVP");
            /*Object[] ret = */lf.Call(i, 20);
        }
Ejemplo n.º 58
0
 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);
     }
 }
Ejemplo n.º 59
0
 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);
     }
 }
Ejemplo n.º 60
0
 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);
     }
 }