Пример #1
0
        public static bool IsStaticPopupVisible()
        {
            GarrisonBase.Debug("LuaCommand: IsStaticPopupVisible");
            const string lua = "return tostring(StaticPopup1:IsVisible())";

            return(Lua.GetReturnVal <bool>(lua, 0));
        }
Пример #2
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);
        }
Пример #3
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));
        }
Пример #4
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));
        }
Пример #5
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));
        }
Пример #6
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));
        }
Пример #7
0
            public void Click()
            {
                GarrisonBase.Debug("LuaCommand: ClickButton {0}", Name);
                String lua = String.Format("{0}:Click()", Name);

                Lua.DoString(lua);
            }
Пример #8
0
            public void AssignFollowers()
            {
                GarrisonBase.Debug("LuaCommand: AssignFollowers");
                string lua = String.Format("{0}('MissionPage1')", LuaEvents.ClickFunctionString);

                Lua.DoString(lua);
            }
Пример #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));
        }
Пример #10
0
        internal static void DetachLuaEventHandlers()
        {
            GarrisonBase.Log("Detaching LUA Event Handlers");
            //Lua.Events.DetachEvent("GARRISON_FOLLOWER_LIST_UPDATE", Coroutines.GarrisonFollowerListUpdate);
            Lua.Events.DetachEvent("GARRISON_MISSION_LIST_UPDATE", GARRISON_MISSION_LIST_UPDATE);
            Lua.Events.DetachEvent("GARRISON_MISSION_STARTED", GARRISON_MISSION_STARTED);
            Lua.Events.DetachEvent("GARRISON_MISSION_FINISHED", GARRISON_MISSION_FINISHED);

            Lua.Events.DetachEvent("GARRISON_MISSION_NPC_OPENED", GARRISON_MISSION_NPC_OPENED);
            Lua.Events.DetachEvent("GARRISON_MISSION_NPC_CLOSED", GARRISON_MISSION_NPC_CLOSED);
            Lua.Events.DetachEvent("GARRISON_SHOW_LANDING_PAGE", GARRISON_SHOW_LANDING_PAGE);
            Lua.Events.DetachEvent("GARRISON_BUILDING_ACTIVATABLE", GARRISON_BUILDING_ACTIVATABLE);

            Lua.Events.DetachEvent("SHIPMENT_CRAFTER_OPENED", SHIPMENT_CRAFTER_OPENED);
            Lua.Events.DetachEvent("SHIPMENT_CRAFTER_CLOSED", SHIPMENT_CRAFTER_CLOSED);

            Lua.Events.DetachEvent("LOOT_CLOSED", LOOT_CLOSED);
            Lua.Events.DetachEvent("LOOT_OPENED", LOOT_OPENED);

            Lua.Events.DetachEvent("QUEST_COMPLETE", QUEST_COMPLETE);
            Lua.Events.DetachEvent("QUEST_PROGRESS", QUEST_PROGRESS);
            Lua.Events.DetachEvent("QUEST_DETAIL", QUEST_DETAIL);
            Lua.Events.DetachEvent("QUEST_FINISHED", QUEST_FINISHED);
            Lua.Events.DetachEvent("QUEST_LOG_UPDATE", QUEST_LOG_UPDATE);
            Lua.Events.DetachEvent("QUEST_REMOVED", QUEST_REMOVED);
            Lua.Events.DetachEvent("QUEST_ACCEPTED", QUEST_ACCEPTED);
            Lua.Events.DetachEvent("QUEST_WATCH_UPDATE", QUEST_WATCH_UPDATE);

            Lua.Events.DetachEvent("GOSSIP_SHOW", GOSSIP_SHOW);
            Lua.Events.DetachEvent("GOSSIP_CLOSED", GOSSIP_CLOSED);

            Lua.Events.DetachEvent("TRADE_SKILL_CLOSE", TRADE_SKILL_CLOSE);
            Lua.Events.DetachEvent("TRADE_SKILL_SHOW", TRADE_SKILL_SHOW);

            Lua.Events.DetachEvent("BAG_UPDATE", BAG_UPDATE);
            Lua.Events.DetachEvent("PLAYERBANKSLOTS_CHANGED", PLAYERBANKSLOTS_CHANGED);
            Lua.Events.DetachEvent("PLAYERREAGENTBANKSLOTS_CHANGED", PLAYERREAGENTBANKSLOTS_CHANGED);

            Lua.Events.DetachEvent("ZONE_CHANGED", ZONE_CHANGED);
            Lua.Events.DetachEvent("ZONE_CHANGED_NEW_AREA", ZONE_CHANGED_NEW_AREA);

            Lua.Events.DetachEvent("MERCHANT_SHOW", MERCHANT_SHOW);
            Lua.Events.DetachEvent("MERCHANT_CLOSED", MERCHANT_CLOSED);

            Lua.Events.DetachEvent("CURRENT_SPELL_CAST_CHANGED", CURRENT_SPELL_CAST_CHANGED);

            Lua.Events.DetachEvent("UI_ERROR_MESSAGE", UI_ERROR_MESSAGE);

            Lua.Events.DetachEvent("CURRENCY_DISPLAY_UPDATE", CURRENCY_DISPLAY_UPDATE);

            Lua.Events.DetachEvent("MAIL_SHOW", MAIL_SHOW);
            Lua.Events.DetachEvent("MAIL_CLOSED", MAIL_CLOSED);

            Lua.Events.DetachEvent("TAXIMAP_OPENED", TAXIMAP_OPENED);
            Lua.Events.DetachEvent("TAXIMAP_CLOSED", TAXIMAP_CLOSED);


            LuaEventsAttached = false;
        }
Пример #11
0
 public static void GARRISON_SHOW_LANDING_PAGE(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent(String.Format("LuaEvent: {0}", "Garrison Landing Page Shown!"));
     if (OnGarrisonLandingPageShow != null)
     {
         OnGarrisonLandingPageShow();
     }
 }
Пример #12
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);
        }
Пример #13
0
 public static void TAXIMAP_CLOSED(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent("LuaEvent: TAXIMAP_CLOSED");
     if (OnTaxiMapClosed != null)
     {
         OnTaxiMapClosed();
     }
 }
Пример #14
0
 public static void GARRISON_MISSION_NPC_CLOSED(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent(String.Format("LuaEvent: {0}", "Garrison Mission NPC Closed!"));
     if (OnGarrisonMissionNpcClosed != null)
     {
         OnGarrisonMissionNpcClosed();
     }
 }
Пример #15
0
 public static void PLAYERREAGENTBANKSLOTS_CHANGED(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent("LuaEvent: PLAYERREAGENTBANKSLOTS_CHANGED");
     if (OnPlayerReagentsBankSlotsChanged != null)
     {
         OnPlayerReagentsBankSlotsChanged();
     }
 }
Пример #16
0
 public static void GARRISON_MISSION_LIST_UPDATE(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent(String.Format("LuaEvent: {0}", "Garrison Mission List Updated!"));
     if (OnGarrisonMissionListUpdated != null)
     {
         OnGarrisonMissionListUpdated();
     }
 }
Пример #17
0
 public static void GARRISON_FOLLOWER_LIST_UPDATE(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent(String.Format("LuaEvent: {0}", "Garrison Follower List Updated!"));
     if (OnGarrisonFollowerListUpdated != null)
     {
         OnGarrisonFollowerListUpdated();
     }
 }
Пример #18
0
 public static void MERCHANT_SHOW(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent("LuaEvent: MERCHANT_SHOW");
     if (OnMerchantShow != null)
     {
         OnMerchantShow();
     }
 }
Пример #19
0
 public static void MERCHANT_CLOSED(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent("LuaEvent: MERCHANT_CLOSED");
     if (OnMerchantClosed != null)
     {
         OnMerchantClosed();
     }
 }
Пример #20
0
 public static void GARRISON_MISSION_STARTED(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent(String.Format("LuaEvent: {0}", "Garrison Mission Started!"));
     if (OnGarrisonMissionStarted != null)
     {
         OnGarrisonMissionStarted();
     }
 }
Пример #21
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);
        }
Пример #22
0
 public static void QUEST_LOG_UPDATE(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent("LuaEvent: QUEST_LOG_UPDATE");
     if (OnQuestLogUpdate != null)
     {
         OnQuestLogUpdate();
     }
 }
Пример #23
0
 public static void BAG_UPDATE(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent("LuaEvent: BAG_UPDATE");
     if (OnBagUpdate != null)
     {
         OnBagUpdate();
     }
 }
Пример #24
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);
            }
Пример #25
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);
        }
Пример #26
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);
            }
Пример #27
0
 public static void GARRISON_MISSION_FINISHED(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent("LuaEvent: GARRISON_MISSION_FINISHED");
     if (OnGarrisonMissionFinished != null)
     {
         OnGarrisonMissionFinished();
     }
 }
Пример #28
0
 public static void GARRISON_BUILDING_ACTIVATABLE(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent("LuaEvent: GARRISON_BUILDING_ACTIVATABLE");
     if (OnGarrisonBuildingActivatable != null)
     {
         OnGarrisonBuildingActivatable();
     }
 }
Пример #29
0
 public static void MAIL_CLOSED(object sender, LuaEventArgs args)
 {
     GarrisonBase.DebugLuaEvent("LuaEvent: MAIL_CLOSED");
     MailOpen = false;
     if (OnMailClosed != null)
     {
         OnMailClosed();
     }
 }
Пример #30
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);
        }