Thread Tools Display Modes
12-29-16, 04:51 PM   #1
TheOldSouls
A Defias Bandit
Join Date: Dec 2016
Posts: 2
Help with some coding I can't seem to configure

I'm Trying to make an addon that can return to me values of how much total artifact power I have across all my weapons on a given character, however I want to use the LibArtifact addon information in order to return these values (since from what I gather without using anything else you can only return information on one weapon at a time). If anyone can help me with this i'd be very appreciative. I am fairly new to this stuff and this is the first time I've really ever tried. If I need to put some code snippets up for what I have so far, just let me know and I can.

Thanks ahead of time!
Main.lua
Code:
local PaenitetTotalArtifactPower = CreateFrame("frame","PaenitetTotalArtifactPowerFrame",UIParent)
PaenitetTotalArtifactPower:SetScript("OnEvent", function(self, event, ...) if self[event] then return self[event](self, event, ...) end end)

local multiplier = {100, 400, 725, 1075, 1450, 1850, 2275, 2725, 3250, 3875, 4625, 5500, 6500, 13340, 22170, 33450, 47850, 66470, 90470, 121070, 160590, 211470, 276270, 358770, 464050, 602700, 785480, 1026350, 1341870, 1759430, 2305430, 3023630, 3970290, 5216130, 6851330, 8766330, 10776330, 12886330, 15101330, 17426330, 19866330, 22426330, 25116330, 27941330, 30906330, 34021330, 37291330, 40726330, 44331330, 48116330, 52091330, 56266330, 60651330, 65256330}

local function GetArtifactPower()
	local total = 0
	if HasArtifactEquipped() then
		powerAvailable = select(5, C_ArtifactUI.GetEquippedArtifactInfo())
		ranksPurchased = select(6, C_ArtifactUI.GetEquippedArtifactInfo())
		total = powerAvailable + multiplier[ranksPurchased]
		DEFAULT_CHAT_FRAME:AddMessage("|cffFF6EB4PaenitetTotalArtifactPower|r")
		DEFAULT_CHAT_FRAME:AddMessage("|cff00ccffRanks Purchased:|r "..tostring(ranksPurchased).."  |cff3587ff(does not include relics)|r")
		DEFAULT_CHAT_FRAME:AddMessage("|cff00ccffPower Available:|r "..tostring(powerAvailable))
		DEFAULT_CHAT_FRAME:AddMessage("|cff00ccffPower Spent On Ranks:|r "..tostring(multiplier[ranksPurchased]))
		DEFAULT_CHAT_FRAME:AddMessage("|cffFF6EB4Total Power On Artifact:|r "..tostring(total))
	else
		DEFAULT_CHAT_FRAME:AddMessage("|cFF99CC33PaenitetTotalArtifactPower:|r No artifact equipped")
	end
end

function PaenitetTotalArtifactPower:PLAYER_LOGIN()

	SLASH_PAENITETTOTALARTIFACTPOWER1 = "/ptap"
	SlashCmdList["PAENITETTOTALARTIFACTPOWER"] = function(msg)
		GetArtifactPower()
	end
	
	local ver = GetAddOnMetadata("PaenitetTotalArtifactPower","Version") or '1.0'
	DEFAULT_CHAT_FRAME:AddMessage(string.format("|cFF99CC33%s|r [v|cFFDF2B2B%s|r] Loaded /ptap", "PaenitetTotalArtifactPower", ver or "1.0"))
end

if IsLoggedIn() then PaenitetTotalArtifactPower:PLAYER_LOGIN() else PaenitetTotalArtifactPower:RegisterEvent("PLAYER_LOGIN") end

Last edited by TheOldSouls : 12-29-16 at 05:51 PM. Reason: Added Code.
  Reply With Quote
01-01-17, 10:51 AM   #2
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
Here is code to get the in-bag artifact data
Lua Code:
  1. for i = 1, NUM_BAG_FRAMES do
  2.     for j = 1, GetContainerNumSlots(i) do
  3.         if select(4, GetContainerItemInfo(i, j)) == 6 then
  4.             SocketContainerItem(i, j)
  5.             print(C_ArtifactUI.GetArtifactInfo())
  6.             ArtifactFrame:Hide()
  7.         end
  8.     end
  9. end
  Reply With Quote
01-01-17, 12:05 PM   #3
TheOldSouls
A Defias Bandit
Join Date: Dec 2016
Posts: 2
Thanks! That's what I couldn't figure out.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help with some coding I can't seem to configure


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off