05-27-22, 03:53 PM | #1 |
Copy gold to clipboard
I wonder if there is something that could do this. I have one addon that actually has an export frame and shows me text from the gold in that raid, that I can than highlight and copy. I wonder if I can get something similar.
If not a direct copy of my gold value, a frame were I can automatically highlight the gold I have and copy to clipboard. Many thanks. |
|
05-27-22, 04:04 PM | #2 | |
You can't "programatically" send text to the clipboard. You need the frame to display the text that you then select and CTRL-C to get it onto the clipboard.
You can create a frame with an EditBox and automaticaly set it to select some text (EditBox:HighlightText(start, end)) so you just need to CTRL-C to copy to the clipboard. Edit: I missed the bit where you were asking for a popup frame if that was the only way. You can paste the following into the website addon.bool.no and give it a unique title (GetGold?) to create/download a small addon to do this. /gg will show/hide the frame with your current gold/silver/copper (the button will toggle current character/all characters) ready to copy (CTRL-C).Pasting the text into an editor will paste the numbers but not the icons.
Lua Code:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 06-03-22 at 03:01 PM. Reason: Added popup frame code extras |
||
05-30-22, 06:19 PM | #3 |
Ty, this is perfect and exactly what I was looking for.
Small addtion if possible please, this is showing the gold of only the current char. Would it be possible to show the gold of all the chars in my account added up? Last edited by Believe82 : 05-30-22 at 06:36 PM. |
|
05-31-22, 12:21 PM | #4 |
You can't get this information for other characters, just the one currently logged on.
It requires a bunch of code to save data as each character logs on/off or has their bank balance updated. It would be something I would think an alt. oriented addon might provide.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. |
|
05-31-22, 03:37 PM | #5 |
Is it possible for me to access an other addons data?
Elvui saves and shows the gold for all my chars I wonder if it would be possible to fetch that data. This is how they show: Is it possible to fetch their data to the frame? (I didn't link their gold.lua cause I didn't know if it would be breaking any coders rule of not sharing other peoples addons code here) Last edited by Believe82 : 06-01-22 at 12:10 AM. |
|
06-01-22, 08:19 PM | #6 |
You could probably get the information from the Elvui SavedVariables but I've never used the addon and have no idea how it's data is structured.
It's global information and using it to display information in your addon wouldn't be a problem.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. |
|
06-02-22, 10:50 PM | #7 |
This is Elvui Gold.lua
Does it help? Code:
local E, L, V, P, G = unpack(ElvUI) local DT = E:GetModule('DataTexts') local B = E:GetModule('Bags') local _G = _G local type, wipe, pairs, ipairs, sort = type, wipe, pairs, ipairs, sort local format, strjoin, tinsert = format, strjoin, tinsert local GetMoney = GetMoney local IsControlKeyDown = IsControlKeyDown local IsLoggedIn = IsLoggedIn local IsShiftKeyDown = IsShiftKeyDown local C_WowTokenPublic_UpdateMarketPrice = C_WowTokenPublic.UpdateMarketPrice local C_WowTokenPublic_GetCurrentMarketPrice = C_WowTokenPublic.GetCurrentMarketPrice local C_Timer_NewTicker = C_Timer.NewTicker local BreakUpLargeNumbers = BreakUpLargeNumbers -- GLOBALS: ElvDB local Profit, Spent, Ticker = 0, 0 local resetCountersFormatter = strjoin('', '|cffaaaaaa', L["Reset Session Data: Hold Ctrl + Right Click"], '|r') local resetInfoFormatter = strjoin('', '|cffaaaaaa', L["Reset Character Data: Hold Shift + Right Click"], '|r') local CURRENCY = CURRENCY local PRIEST_COLOR = RAID_CLASS_COLORS.PRIEST local C_CurrencyInfo_GetBackpackCurrencyInfo = C_CurrencyInfo.GetBackpackCurrencyInfo local iconString = '|T%s:16:16:0:0:64:64:4:60:4:60|t' local menuList = {} local function sortFunction(a, b) return a.amount > b.amount end local function OnEvent(self) if not IsLoggedIn() then return end if E.Retail and not Ticker then C_WowTokenPublic_UpdateMarketPrice() Ticker = C_Timer_NewTicker(60, C_WowTokenPublic_UpdateMarketPrice) end ElvDB = ElvDB or {} ElvDB.gold = ElvDB.gold or {} ElvDB.gold[E.myrealm] = ElvDB.gold[E.myrealm] or {} ElvDB.class = ElvDB.class or {} ElvDB.class[E.myrealm] = ElvDB.class[E.myrealm] or {} ElvDB.class[E.myrealm][E.myname] = E.myclass ElvDB.faction = ElvDB.faction or {} ElvDB.faction[E.myrealm] = ElvDB.faction[E.myrealm] or {} ElvDB.faction[E.myrealm][E.myname] = E.myfaction ElvDB.serverID = ElvDB.serverID or {} ElvDB.serverID[E.serverID] = ElvDB.serverID[E.serverID] or {} ElvDB.serverID[E.serverID][E.myrealm] = true --prevent an error possibly from really old profiles local oldMoney = ElvDB.gold[E.myrealm][E.myname] if oldMoney and type(oldMoney) ~= 'number' then ElvDB.gold[E.myrealm][E.myname] = nil oldMoney = nil end local NewMoney = GetMoney() ElvDB.gold[E.myrealm][E.myname] = NewMoney local OldMoney = oldMoney or NewMoney local Change = NewMoney-OldMoney -- Positive if we gain money if OldMoney>NewMoney then -- Lost Money Spent = Spent - Change else -- Gained Moeny Profit = Profit + Change end self.text:SetText(E:FormatMoney(NewMoney, E.global.datatexts.settings.Gold.goldFormat or "BLIZZARD", not E.global.datatexts.settings.Gold.goldCoins)) end local function deleteCharacter(self, realm, name) ElvDB.gold[realm][name] = nil ElvDB.class[realm][name] = nil ElvDB.faction[realm][name] = nil if name == E.myname and realm == E.myrealm then OnEvent(self) end end local function Click(self, btn) if btn == 'RightButton' then if IsShiftKeyDown() then wipe(menuList) tinsert(menuList, { text = 'Delete Character', isTitle = true, notCheckable = true }) for realm in pairs(ElvDB.serverID[E.serverID]) do for name in pairs(ElvDB.gold[realm]) do tinsert(menuList, { text = format('%s - %s', name, realm), notCheckable = true, func = function() deleteCharacter(self, realm, name) end }) end end DT:SetEasyMenuAnchor(DT.EasyMenu, self) _G.EasyMenu(menuList, DT.EasyMenu, nil, nil, nil, 'MENU') elseif IsControlKeyDown() then Profit = 0 Spent = 0 end else _G.ToggleAllBags() end end local myGold = {} local function OnEnter() DT.tooltip:ClearLines() local textOnly = not E.global.datatexts.settings.Gold.goldCoins and true or false local style = E.global.datatexts.settings.Gold.goldFormat or 'BLIZZARD' DT.tooltip:AddLine(L["Session:"]) DT.tooltip:AddDoubleLine(L["Earned:"], E:FormatMoney(Profit, style, textOnly), 1, 1, 1, 1, 1, 1) DT.tooltip:AddDoubleLine(L["Spent:"], E:FormatMoney(Spent, style, textOnly), 1, 1, 1, 1, 1, 1) if Profit < Spent then DT.tooltip:AddDoubleLine(L["Deficit:"], E:FormatMoney(Profit-Spent, style, textOnly), 1, 0, 0, 1, 1, 1) elseif (Profit-Spent)>0 then DT.tooltip:AddDoubleLine(L["Profit:"], E:FormatMoney(Profit-Spent, style, textOnly), 0, 1, 0, 1, 1, 1) end DT.tooltip:AddLine(' ') local totalGold, totalHorde, totalAlliance = 0, 0, 0 DT.tooltip:AddLine(L["Character: "]) wipe(myGold) for realm in pairs(ElvDB.serverID[E.serverID]) do for k, _ in pairs(ElvDB.gold[realm]) do if ElvDB.gold[realm][k] then local color = E:ClassColor(ElvDB.class[realm][k]) or PRIEST_COLOR tinsert(myGold, { name = k, realm = realm, amount = ElvDB.gold[realm][k], amountText = E:FormatMoney(ElvDB.gold[realm][k], style, textOnly), faction = ElvDB.faction[realm][k] or '', r = color.r, g = color.g, b = color.b, } ) end if ElvDB.faction[realm][k] == 'Alliance' then totalAlliance = totalAlliance+ElvDB.gold[realm][k] elseif ElvDB.faction[realm][k] == 'Horde' then totalHorde = totalHorde+ElvDB.gold[realm][k] end totalGold = totalGold+ElvDB.gold[realm][k] end end sort(myGold, sortFunction) for _, g in ipairs(myGold) do local nameLine = '' if g.faction ~= '' and g.faction ~= 'Neutral' then nameLine = format([[|TInterface\FriendsFrame\PlusManz-%s:14|t ]], g.faction) end local toonName = format('%s%s%s', nameLine, g.name, (g.realm and g.realm ~= E.myrealm and ' - '..g.realm) or '') DT.tooltip:AddDoubleLine((g.name == E.myname and toonName..[[ |TInterface\COMMON\Indicator-Green:14|t]]) or toonName, g.amountText, g.r, g.g, g.b, 1, 1, 1) end DT.tooltip:AddLine(' ') DT.tooltip:AddLine(L["Server: "]) if totalAlliance > 0 and totalHorde > 0 then if totalAlliance ~= 0 then DT.tooltip:AddDoubleLine(L["Alliance: "], E:FormatMoney(totalAlliance, style, textOnly), 0, .376, 1, 1, 1, 1) end if totalHorde ~= 0 then DT.tooltip:AddDoubleLine(L["Horde: "], E:FormatMoney(totalHorde, style, textOnly), 1, .2, .2, 1, 1, 1) end DT.tooltip:AddLine(' ') end DT.tooltip:AddDoubleLine(L["Total: "], E:FormatMoney(totalGold, style, textOnly), 1, 1, 1, 1, 1, 1) if E.Retail then DT.tooltip:AddLine(' ') DT.tooltip:AddDoubleLine(L["WoW Token:"], E:FormatMoney(C_WowTokenPublic_GetCurrentMarketPrice() or 0, style, textOnly), 0, .8, 1, 1, 1, 1) end if E.Retail then for i = 1, _G.MAX_WATCHED_TOKENS do local info = C_CurrencyInfo_GetBackpackCurrencyInfo(i) if info then if i == 1 then DT.tooltip:AddLine(' ') DT.tooltip:AddLine(CURRENCY) end if info.quantity then DT.tooltip:AddDoubleLine(format('%s %s', format(iconString, info.iconFileID), info.name), BreakUpLargeNumbers(info.quantity), 1, 1, 1, 1, 1, 1) end end end end local grayValue = B:GetGraysValue() if grayValue > 0 then DT.tooltip:AddLine(' ') DT.tooltip:AddDoubleLine(L["Grays"], E:FormatMoney(grayValue, style, textOnly), nil, nil, nil, 1, 1, 1) end DT.tooltip:AddLine(' ') DT.tooltip:AddLine(resetCountersFormatter) DT.tooltip:AddLine(resetInfoFormatter) DT.tooltip:Show() end DT:RegisterDatatext('Gold', nil, {'PLAYER_MONEY', 'SEND_MAIL_MONEY_CHANGED', 'SEND_MAIL_COD_CHANGED', 'PLAYER_TRADE_MONEY', 'TRADE_MONEY_CHANGED'}, OnEvent, nil, Click, OnEnter, nil, L["Gold"]) |
|
06-03-22, 11:06 AM | #8 |
Not really because way too lazy.
I've updated the code in my OP to add totals for characters. In order to get it to work properly you will need to follow the Notes after copy/pasting/downloading/installing the new version of the addon. A copy of the notes is also at the end of the code.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. |
|
06-03-22, 12:11 PM | #9 |
Ty! this works perfectly.
It is exactly what I needed and wanted. Love the nice button touch of changing between all and single char. |
|
WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Copy gold to clipboard |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|