Example #1
0
        public static bool IsQuestFlaggedCompleted(string ID)
        {
            GarrisonBase.Debug("LuaCommand: IsQuestFlaggedCompleted {0}", ID);
            string lua = String.Format("return tostring(IsQuestFlaggedCompleted(\"{0}\"))", ID);

            return(Lua.GetReturnVal <bool>(String.Format("return IsQuestFlaggedCompleted(\"{0}\")", ID), 0));
        }
Example #2
0
        public static int GetNumberContainerSlots(int index)
        {
            GarrisonBase.Debug("LuaCommand: GetNumberContainerSlots");
            string lua = String.Format("return GetContainerNumSlots({0})", index);

            return(Lua.GetReturnVal <int>(lua, 0));
        }
Example #3
0
        internal static async Task <bool> InjectLuaAddon()
        {
            GarrisonBase.Debug("Injecting Lua Code..");

            String luaCode = String.Format("{0} " +
                                           "function {4}() {1} " +
                                           "function {5}(button_name) {2} " +
                                           "function {6}(mission_id) {3}",
                                           Resources.LuaStringAddon,
                                           Resources.LuaStringAddonTest,
                                           Resources.LuaStringAddonClickButton,
                                           Resources.LuaStringAddonSuccess,
                                           TestFunctionString,
                                           ClickFunctionString,
                                           SuccessFunctionString);

            GarrisonBase.Debug("TestFunctionString {0}\r\nClickFunctionString {1}\r\nSuccessFunctionString {2}",
                               TestFunctionString, ClickFunctionString, SuccessFunctionString);

            await Coroutine.Yield();

            Lua.DoString(luaCode, "clicky.lua");
            await Coroutine.Sleep(1000);

            return(false);
        }
Example #4
0
        public static int GetCurrencyCount(int currencyId)
        {
            GarrisonBase.Debug("LuaCommand: GetCurrencyInfo");
            string lua = String.Format("return GetCurrencyInfo({0})", currencyId);

            return(Lua.GetReturnVal <int>(lua, 1));
        }
Example #5
0
        public static bool IsStaticPopupVisible()
        {
            GarrisonBase.Debug("LuaCommand: IsStaticPopupVisible");
            const string lua = "return tostring(StaticPopup1:IsVisible())";

            return(Lua.GetReturnVal <bool>(lua, 0));
        }
Example #6
0
            public void AssignFollowers()
            {
                GarrisonBase.Debug("LuaCommand: AssignFollowers");
                string lua = String.Format("{0}('MissionPage1')", LuaEvents.ClickFunctionString);

                Lua.DoString(lua);
            }
Example #7
0
            public void Click()
            {
                GarrisonBase.Debug("LuaCommand: ClickButton {0}", Name);
                String lua = String.Format("{0}:Click()", Name);

                Lua.DoString(lua);
            }
Example #8
0
        public static bool GetBagSlotFlag(int bagIndex, int flag)
        {
            GarrisonBase.Debug("LuaCommand: GetBagSlotFlag");
            string lua = String.Format("return tostring(GetBagSlotFlag(\"{0}\", \"{1}\"))", bagIndex, flag);

            return(Lua.GetReturnVal <bool>(lua, 0));
        }
Example #9
0
        public static WorkOrder GetWorkOrder(int buildingId)
        {
            GarrisonBase.Debug("LuaCommand: GetWorkOrder {0}", buildingId);
            List <string> workorderinfo = Lua.GetReturnValues(String.Format("return C_Garrison.GetLandingPageShipmentInfo(\"{0}\")", buildingId));

            if (workorderinfo.Count < 2)
            {
                return(null);
            }

            BuildingType  buildingType  = Building.GetBuildingTypeUsingId(buildingId);
            WorkOrderType workorderType = WorkOrder.GetWorkorderType(buildingType);
            int           MaxOrders     = workorderinfo[2].ToInt32();

            Tuple <CraftingReagents, int>[] price = WorkOrder.GetWorkOrderItemAndQuanityRequired(workorderType);
            int PendingOrders = 0;
            int PickupOrders  = 0;

            if (workorderinfo.Count > 3)
            {
                PickupOrders  = workorderinfo[3].ToInt32();
                PendingOrders = workorderinfo[4].ToInt32();
            }

            if (price == null)
            {
                PendingOrders = 0;
                PickupOrders  = 0;
                MaxOrders     = 0;
                price         = new[] { new Tuple <CraftingReagents, int>(CraftingReagents.None, 9999) };
            }

            return(new WorkOrder(buildingId, buildingType, workorderType, MaxOrders, price, PendingOrders, PickupOrders));
        }
Example #10
0
        public static bool TestLuaInjectionCode()
        {
            GarrisonBase.Debug("LuaCommand: {0}", String.Format("return {0}()", LuaEvents.TestFunctionString));
            string        lua       = String.Format("return {0}()", LuaEvents.TestFunctionString);
            List <string> retvalues = Lua.GetReturnValues(lua, "clicky.lua");

            return(retvalues != null);
        }
Example #11
0
            public bool IsVisible()
            {
                String lua = String.Format("return {0}:IsVisible()", Name);
                bool   ret = Lua.GetReturnVal <bool>(lua, 0);

                GarrisonBase.Debug("LuaCommand: IsFrameVisible {0} {1}", Name, ret);
                return(ret);
            }
Example #12
0
            public bool IsEnabled()
            {
                String lua = String.Format("return {0}:IsEnabled()", Name);
                var    ret = Lua.GetReturnVal <bool>(lua, 0);

                GarrisonBase.Debug("LuaCommand: IsButtonEnabled {0} {1}", Name, ret);
                return(ret);
            }
Example #13
0
        public static bool IsAddonLoaded(string AddonName)
        {
            var luastr   = String.Format("return GetAddOnEnableState(\"{0}\",\"{1}\")", StyxWoW.Me.Name, AddonName);
            var retValue = Lua.GetReturnVal <int>(luastr, 0);

            GarrisonBase.Debug("LuaCommand: GetAddOnEnableState {0} == ({1})", AddonName, retValue);
            return(retValue > 0);
        }
Example #14
0
        public static bool IsFollowerCollected(int id)
        {
            GarrisonBase.Debug("LuaCommand: IsFollowerCollected {0}", id);
            String lua  = String.Format("return C_Garrison.IsFollowerCollected(\"{0}\");", id);
            var    info = Lua.GetReturnVal <int>(lua, 0);

            return(info == 1);
        }
Example #15
0
        public static void GetBuildingInfo(int buildingId, out string plotId, out bool canActivate, out int shipCap, out int shipReady, out int shipTotal, out bool isBuilding)
        {
            //BUG: Changed ur Temp to a local var, but it might f**k shit up if u wanted to use Temp in other methods
            String lua =
                "C_Garrison.RequestLandingPageShipmentInfo();" +
                "local RetInfo = {}; local Temp = {}; local buildings = C_Garrison.GetBuildings();" +
                String.Format(
                    "for i = 1, #buildings do " +
                    "local buildingID = buildings[i].buildingID;" +
                    "if (buildingID == {0}) then " +
                    "local nameShipment, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, itemName, itemIcon, itemQuality, itemID = C_Garrison.GetLandingPageShipmentInfo(buildingID);" +
                    "local id, name, texPrefix, icon, rank, isBuilding, timeStart, buildTime, canActivate, canUpgrade, isPrebuilt = C_Garrison.GetOwnedBuildingInfoAbbrev(buildings[i].plotID);" +
                    "Temp[0] = buildings[i].buildingID;" +
                    "Temp[1] = buildings[i].plotID;" +
                    "Temp[2] = buildings[i].buildingLevel;" +
                    "Temp[3] = name;" +
                    "Temp[4] = rank;" +
                    "if (not isBuilding) then Temp[5] =  0; else Temp[5] = isBuilding;end;" +
                    "Temp[6] = timeStart;" +
                    "Temp[7] = buildTime;" +
                    "if (not canActivate) then Temp[8] =  0; else Temp[8] = canActivate;end;" +
                    "Temp[9] = canUpgrade;" +
                    "Temp[11] = isPrebuilt;" +
                    // Info on shipments
                    "Temp[12] = nameShipment;" +
                    "if (not shipmentCapacity) then Temp[13] =  0; else Temp[13] = shipmentCapacity;end;" +
                    "if (not shipmentsReady) then Temp[14] = 0; else Temp[14] = shipmentsReady;end;" +
                    "if (not shipmentsTotal) then Temp[15] =  0; else Temp[15] = shipmentsTotal;end;" +
                    "Temp[16] = creationTime;" +
                    "Temp[17] = duration;" +
                    "Temp[18] = itemName;" +
                    "Temp[19] = itemQuality;" +
                    "Temp[20] = itemID;" +
                    "end;" +
                    "end;" +
                    "for j_=0,20 do table.insert(RetInfo,tostring(Temp[j_]));end; " +
                    "return unpack(RetInfo)", buildingId);
            List <String> building = Lua.GetReturnValues(lua);

            //int id = building[0].ToInt32();

            plotId      = building[1];
            canActivate = building[8].ToBoolean();
            isBuilding  = building[5].ToBoolean();
            string shipmentsReady = building[15];
            string shipmentsTotal = building[14];
            string shipmentsCap   = building[13];

            shipCap   = Convert.ToInt32(shipmentsCap);
            shipReady = Convert.ToInt32(shipmentsReady);
            shipTotal = Convert.ToInt32(shipmentsTotal);

            GarrisonBase.Debug("LuaCommand: GetBuildingInfo {0} canActivate {1} " +
                               "isBuilding {2} shipmentsReady {3} shipmentsTotal {4} " +
                               "shipmentsCap {5}",
                               buildingId, canActivate, isBuilding, shipmentsReady, shipmentsTotal, shipmentsCap);
        }
Example #16
0
        public static bool ClickStartOrderButtonEnabled()
        {
            //CreateAllWorkOrdersButton
            const string lua = "return GarrisonCapacitiveDisplayFrame.StartWorkOrderButton:IsEnabled()";

            var ret = Lua.GetReturnVal <bool>(lua, 0);

            GarrisonBase.Debug("LuaCommand: ClickStartOrderButtonEnabled {0}", ret);
            return(ret);
        }
Example #17
0
        public static double GetMissionBestSuccessAttempt(int missionId, out int[] followerIds)
        {
            GarrisonBase.Debug("LuaCommand: GetMissionBestSuccessAttempt");
            followerIds = new[] { 0, 0, 0 };
            string lua = String.Format(
                "local yieldInfo = {0}({1});", LuaEvents.SuccessFunctionString, missionId) +
                         "local Ret = {};" +
                         "table.insert(Ret,tonumber(yieldInfo.totalfollowers));" +
                         "table.insert(Ret,tonumber(yieldInfo[1].garrFollowerID));" +
                         "if (yieldInfo.totalfollowers>1) then table.insert(Ret,tonumber(yieldInfo[2].garrFollowerID)); end;" +
                         "if (yieldInfo.totalfollowers>2) then table.insert(Ret,tonumber(yieldInfo[3].garrFollowerID)); end;" +
                         "table.insert(Ret,yieldInfo.successChance);" +
                         "table.insert(Ret,tostring(yieldInfo.gr_rewards));" +
                         "table.insert(Ret,tostring(yieldInfo.goldReward));" +
                         "table.insert(Ret,tostring(yieldInfo.itemID));" +
                         "table.insert(Ret,tostring(yieldInfo.currencyID));" +
                         "table.insert(Ret,tostring(yieldInfo.followerXP));" +
                         "table.insert(Ret,tostring(yieldInfo.apexReward));" +
                         "return unpack(Ret)";
            List <string> retvalues     = Lua.GetReturnValues(lua, "clicky.lua");
            double        successChance = 0;

            try
            {
                if (retvalues.Count == 0)
                {
                    //failed!
                }
                else
                {
                    int totalfollowers = retvalues[0].ToInt32();
                    followerIds[0] = Convert.ToInt32(retvalues[1]);
                    int nextIndex = 2;
                    if (totalfollowers > 1)
                    {
                        followerIds[1] = Convert.ToInt32(retvalues[2]);
                        nextIndex++;

                        if (totalfollowers > 2)
                        {
                            followerIds[2] = Convert.ToInt32(retvalues[3]);
                            nextIndex++;
                        }
                    }
                    successChance = Convert.ToDouble(retvalues[nextIndex]);
                }
            }
            catch (Exception)
            {
                GarrisonBase.Debug("LuaCommandException: GetMissionBestSuccessAttempt");
            }


            return(successChance);
        }
Example #18
0
        public static bool IsGarrisonCapacitiveDisplayFrame()
        {
            const string lua =
                "if not GarrisonCapacitiveDisplayFrame then return false; else return tostring(GarrisonCapacitiveDisplayFrame:IsVisible());end;";
            string t   = Lua.GetReturnValues(lua)[0];
            bool   ret = t.ToBoolean();



            GarrisonBase.Debug("LuaCommand: IsGarrisonCapacitiveDisplayFrame {0}", ret);
            return(ret);
        }
Example #19
0
        public static int GetMissionBonusChance(int missionId)
        {
            GarrisonBase.Debug("LuaCommand: GetMissionBonusChance");
            String lua = String.Format("return tostring(C_Garrison.GetRewardChance(\"{0}\"))", missionId);
            var    ret = Lua.GetReturnValues(lua);

            if (ret[0] == "nil")
            {
                return(0);
            }
            return(Convert.ToInt32(ret[0]));
        }
Example #20
0
        public static List <int> GetBuildingIds()
        {
            GarrisonBase.Debug("LuaCommand: GetBuildingIds");
            String lua =
                "local RetInfo = {}; local buildings = C_Garrison.GetBuildings();" +
                "for i = 1, #buildings do " +
                "table.insert(RetInfo,tostring(buildings[i].buildingID));" +
                "end;" +
                "return unpack(RetInfo)";
            List <string> retValues = Lua.GetReturnValues(lua);

            return(retValues.Select(value => value.ToInt32()).ToList());
        }
Example #21
0
        public static DateTime GetGameTime()
        {
            string        lua       = String.Format("return GetGameTime()");
            List <string> retvalues = Lua.GetReturnValues(lua);

            int      hour     = retvalues[0].ToInt32();
            int      minute   = retvalues[1].ToInt32();
            DateTime now      = DateTime.Now;
            DateTime gameTime = new DateTime(now.Year, now.Month, now.Day, hour, minute, 0);

            GarrisonBase.Debug("LuaCommand: GetGameTime {0}", gameTime.ToString());

            return(gameTime);
        }
Example #22
0
        public static List <int> GetAllFollowerIDs()
        {
            GarrisonBase.Debug("LuaCommand: GetAllFollowerIDs");

            String lua =
                "local RetInfo = {}; local followers = C_Garrison.GetFollowers();" +
                "for i,f in ipairs(followers) do " +
                "local followerID = (f.garrFollowerID) and tonumber(f.garrFollowerID) or f.followerID;" +
                "table.insert(RetInfo,tostring(followerID));" +
                "end;" +
                "return unpack(RetInfo)";
            List <int> info = Lua.GetReturnValues(lua).ConvertAll(s => s.ToInt32());

            return(info);
        }
Example #23
0
            public void OpenMission(int missionId)
            {
                GarrisonBase.Debug("LuaCommand: OpenMission {0}", missionId);
                //Scroll until we see mission first
                var lua =
                    "local mission; local am = {}; C_Garrison.GetAvailableMissions(am);" +
                    String.Format(
                        "for idx = 1, #am do " +
                        "if am[idx].missionID == {0} then " +
                        "mission = am[idx];" +
                        "end;" +
                        "end;" +
                        "GarrisonMissionFrame.MissionTab.MissionList:Hide();" +
                        "GarrisonMissionFrame.MissionTab.MissionPage:Show();" +
                        "GarrisonMissionPage_ShowMission(mission);"
                        , missionId);

                Lua.DoString(lua);
            }
Example #24
0
 public static void CloseTradeSkillFrame()
 {
     GarrisonBase.Debug("LuaCommand: CloseTradeSkillFrame");
     Lua.DoString("TradeSkillFrameCloseButton:Click()");
 }
Example #25
0
 public static void ClickGarrisonMinimapButton()
 {
     GarrisonBase.Debug("LuaCommand: ClickGarrisonMinimapButton");
     Lua.DoString("GarrisonLandingPageMinimapButton:Click()");
 }
Example #26
0
 public static void ReloadUI()
 {
     GarrisonBase.Debug("LuaCommand: ReloadUI");
     Lua.DoString("ReloadUI()");
 }
Example #27
0
 public static void EnableAddon(string AddonName)
 {
     GarrisonBase.Debug("LuaCommand: EnableAddOn {0}", AddonName);
     Lua.DoString(String.Format("EnableAddOn(\"{0}\")", AddonName));
 }
Example #28
0
 public static void ClickSendMailTab()
 {
     //
     GarrisonBase.Debug("LuaCommand: ClickSendMailTab");
     Lua.DoString("MailFrameTab2:Click()");
 }
Example #29
0
 public static void ClickStaticPopupButton(int buttonNumber)
 {
     GarrisonBase.Debug("LuaCommand: ClickStaticPopupButton");
     Lua.DoString(String.Format("StaticPopup1Button{0}:Click()", buttonNumber));
 }
Example #30
0
 public static void ClickStartOrderButton()
 {
     GarrisonBase.Debug("LuaCommand: ClickStartOrderButton");
     Lua.DoString("GarrisonCapacitiveDisplayFrame.StartWorkOrderButton:Click()");
 }