Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EnchantingShuffler = LibStub("AceAddon-3.0"):NewAddon("EnchantingShuffler", "AceConsole-3.0")
- ESAceGUI = LibStub("AceGUI-3.0")
- -----------------------------------------------------------------------
- EnchantingShuffler:RegisterChatCommand("es2", "ESOpen")
- EnchantingShuffler_Opened = "No"
- EnchantingShufflerErrorRunOnce = 0
- EnchantingShuffler_Database = "ESDBPHolder"
- -------------------------------------------------------------------------
- local ESframe = ESAceGUI:Create("Window")
- ESframe:EnableResize(false)
- ESframe:SetTitle("Enchanting Shuffler")
- ESframe:SetWidth(350)
- ESframe:SetHeight(350)
- ESframe:SetLayout("Flow")
- ESframe:Hide()
- local ESEnchantingMaterialsGroup = ESAceGUI:Create("SimpleGroup")
- ESEnchantingMaterialsGroup:SetWidth(60)
- ESEnchantingMaterialsGroup:SetHeight(350)
- ESEnchantingMaterialsGroup:SetFullWidth(true)
- ESframe:AddChild(ESEnchantingMaterialsGroup)
- local ESSpiritDustIcon = ESAceGUI:Create("Icon")
- ESSpiritDustIcon:SetImage("Interface\\ICONS\\inv_misc_powder_copper")
- ESSpiritDustIcon:SetLabel("Spirit Dust")
- ESSpiritDustIcon:SetImageSize(50,50)
- ESSpiritDustIcon:SetCallback("OnEnter", function() ESPricingTooltips("Spirit Dust") end)
- ESSpiritDustIcon:SetCallback("OnLeave", function() HideTooltips() end)
- ESEnchantingMaterialsGroup:AddChild(ESSpiritDustIcon)
- local ESMysteriousEssenceIcon = ESAceGUI:Create("Icon")
- ESMysteriousEssenceIcon:SetImage("Interface\\ICONS\\trade_enchanting_greatermysteriousessence")
- ESMysteriousEssenceIcon:SetLabel("Mysterious Essence")
- ESMysteriousEssenceIcon:SetImageSize(50,50)
- ESMysteriousEssenceIcon:SetCallback("OnEnter", function() ESPricingTooltips("Mysterious Essence") end)
- ESMysteriousEssenceIcon:SetCallback("OnLeave", function() HideTooltips() end)
- ESEnchantingMaterialsGroup:AddChild(ESMysteriousEssenceIcon)
- local ESEtherealShardIcon = ESAceGUI:Create("Icon")
- ESEtherealShardIcon:SetImage("Interface\\ICONS\\trade_enchanting_largeetherealshard")
- ESEtherealShardIcon:SetLabel("Ethereal Shard")
- ESEtherealShardIcon:SetImageSize(50,50)
- ESEtherealShardIcon:SetCallback("OnEnter", function() ESPricingTooltips("Ethereal Shard") end)
- ESEtherealShardIcon:SetCallback("OnLeave", function() HideTooltips() end)
- ESEnchantingMaterialsGroup:AddChild(ESEtherealShardIcon)
- local ESShaCrystalIcon = ESAceGUI:Create("Icon")
- ESShaCrystalIcon:SetImage("Interface\\ICONS\\inv_misc_crystalepic2")
- ESShaCrystalIcon:SetLabel("Sha Crystal")
- ESShaCrystalIcon:SetImageSize(50,50)
- ESShaCrystalIcon:SetCallback("OnEnter", function() ESPricingTooltips("Sha Crystal") end)
- ESShaCrystalIcon:SetCallback("OnLeave", function() HideTooltips() end)
- ESEnchantingMaterialsGroup:AddChild(ESShaCrystalIcon)
- local ESUpPricesGroup = ESAceGUI:Create("SimpleGroup")
- ESUpPricesGroup:SetWidth(60)
- ESUpPricesGroup:SetHeight(350)
- ESUpPricesGroup:SetFullWidth(true)
- ESframe:AddChild(ESUpPricesGroup)
- local ESPriceUpLabel = ESAceGUI:Create("Label")
- ESPriceUpLabel:SetText("UP:")
- ESPriceUpLabel:SetFont("GameFontNormal",30)
- ESPriceUpLabel:SetRelativeWidth(0.5)
- ESUpPricesGroup:AddChild(ESPriceUpLabel)
- --- Slash Commands ---
- function EnchantingShuffler:ESOpen(input)
- if EnchantingShuffler_Opened == "No" then
- EnchantingShuffler_Opened = "Yes"
- ESframe:Show()
- elseif EnchantingShuffler_Opened == "Yes" then
- EnchantingShuffler_Opened = "No"
- ESframe:Hide()
- end
- end
- function ESDatabaseSelection()
- -- Database selection --
- if TSMAPI then
- EnchantingShuffler_Database = "TradeSkillMaster"
- elseif AuctionatorLoaded then
- EnchantingShuffler_Database = "Auctionator"
- else
- if EnchantingShufflerErrorRunOnce == 0 then
- EnchantingShuffler:Print("No database found, please install one of the following databases: TradeSkillMaster_AuctionDB or Auctionator")
- EnchantingShufflerErrorRunOnce = 1
- end
- end
- end
- --- tool tips Pricing Modules ---
- function ESPricingTooltips(ITEM)
- local PriceMin = 0
- local PriceMarket = 0
- local PriceMinEach = 0
- local PriceMarketEach = 0
- if ITEM == "Spirit Dust" then
- PriceMin = EnchantingShuffler_GetValue(74249,"Stack","Min")
- PriceMarket = EnchantingShuffler_GetValue(74249,"Stack","Market")
- PriceMinEach = EnchantingShuffler_GetValue(74249,"Each","Min")
- PriceMarketEach = EnchantingShuffler_GetValue(74249,"Each","Market")
- elseif ITEM == "Mysterious Essence" then
- PriceMin = EnchantingShuffler_GetValue(74250,"Stack","Min")
- PriceMarket = EnchantingShuffler_GetValue(74250,"Stack","Market")
- PriceMinEach = EnchantingShuffler_GetValue(74250,"Each","Min")
- PriceMarketEach = EnchantingShuffler_GetValue(74250,"Each","Market")
- elseif ITEM == "Ethereal Shard" then
- PriceMin = EnchantingShuffler_GetValue(74247,"Stack","Min")
- PriceMarket = EnchantingShuffler_GetValue(74247,"Stack","Market")
- PriceMinEach = EnchantingShuffler_GetValue(74247,"Each","Min")
- PriceMarketEach = EnchantingShuffler_GetValue(74247,"Each","Market")
- elseif ITEM == "Sha Crystal" then
- PriceMin = EnchantingShuffler_GetValue(74248,"Stack","Min")
- PriceMarket = EnchantingShuffler_GetValue(74248,"Stack","Market")
- PriceMinEach = EnchantingShuffler_GetValue(74248,"Each","Min")
- PriceMarketEach = EnchantingShuffler_GetValue(74248,"Each","Market")
- end
- if TSMAPI then
- GameTooltip:ClearLines();
- GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
- GameTooltip:AddLine(ITEM.." details:")
- GameTooltip:AddLine("Each:")
- GameTooltip:AddLine("Lowest price: "..PriceMinEach.."g")
- GameTooltip:AddLine("Market Price: "..PriceMarketEach.."g")
- GameTooltip:AddLine("Per stack:")
- GameTooltip:AddLine("Lowest price: "..PriceMin.."g")
- GameTooltip:AddLine("Market Price: "..PriceMarket.."g")
- GameTooltip:Show();
- elseif AuctionatorLoaded then
- GameTooltip:ClearLines();
- GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
- GameTooltip:AddLine(ITEM.." details:")
- GameTooltip:AddLine("Each:")
- GameTooltip:AddLine("Lowest price: "..PriceMinEach.."g")
- GameTooltip:AddLine("Per stack:")
- GameTooltip:AddLine("Lowest price: "..PriceMin.."g")
- GameTooltip:Show();
- end
- end
- function HideTooltips()
- GameTooltip:Hide()
- end
- --- Price getting --
- function EnchantingShuffler_GetValue(ITEM,TYPE,TSMVar)
- local Price -- create price local
- if EnchantingShuffler_Database == "TradeSkillMaster" then
- if TSMVar == "Market" then
- if TYPE == "Stack" then
- Price = ((TSMAPI:GetItemValue(ITEM,"DBMarket") / 10000) * 20)
- elseif TYPE == "Each" then
- Price = (TSMAPI:GetItemValue(ITEM,"DBMarket") / 10000)
- end
- elseif TSMVar == "Min" or TSMVar == nil then
- if TYPE == "Stack" then
- Price = ((TSMAPI:GetItemValue(ITEM,"DBMinBuyout") / 10000) * 20)
- elseif TYPE == "Each" then
- Price = (TSMAPI:GetItemValue(ITEM,"DBMinBuyout") / 10000)
- end
- end
- -- Auctionator Database --
- elseif EnchantingShuffler_Database == "Auctionator" then
- if TSMVar == "Market" or TSMVar == "Min" or TSMVar == nil or TSMVar == "Market" then
- if TYPE == "Stack" then
- Price = ((GetAuctionBuyout(ITEM) / 10000) * 20)
- elseif TYPE == "Each" then
- Price = (GetAuctionBuyout(ITEM) / 10000)
- end
- end
- else
- if EnchantingShufflerErrorRunOnce == 0 then
- Price = 0
- EnchantingShuffler:Print("No database found, please install on of the following databases: TradeSkillMaster_AuctionDB or Auctionator")
- EnchantingShufflerErrorRunOnce = 1
- end
- end
- if Price == nil or Price == 0 then
- Price = 0
- end
- --EnchantingShuffler:Print(Price)
- return Price
- end
- function EnchantingShuffler:OnEnable()
- ESDatabaseSelection()
- EnchantingShuffler:Print("Yep done")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement