http://paste.wowace.com/3027/ ----As this is just a pastey, copy and paste in to a file.
---- do a find and replace on ' SAVED_VARIABLE_NAME '
---- with the actual name of the saved variable in the ToC File.
Is your cookie. It accounts for things like different toons being in different guilds and even changing guilds mid session.
It also adds in using LDB. So if this particular problem with gold and events ties into your other thread about minimap buttons n' such... then this paste should solve it :)
P.S. Logic errors are a bitch to debug because you (usually) don't get any error messages.
On that same note, to debug logic errors the easiest thing to do is break it apart into as many as needed "If then else end"s as needed or break all your variable movement into one step at a time and use print() & then optimize from there.
fwiw, you probably need a few "tonumber()"s in there to convert your string selections to numbers.
function guildLoot_OnEvent(self, event, msg)
if event == "CHAT_MSG_MONEY" then
local guild = msg:match( "%((.+)%)")
if not guild then return end
local gold = guild:match(goldLoot) or 0
local silver = guild:match(silverLoot) or 0
local copper = guild:match(copperLoot) or 0
local currentTotal = (gold*1000) + (silver*100) + copper
---Set your value in your db or SV at this point
SavedVariableName = (SavedVariableName or 0) + currentTotal
lootAmounts:AddMessage( GetCoinTextureString( SavedVariableName ) )
oh yes, you can mix logic and math together like that :)
I have to reload wow before i can test because of lag spikes.
But i also had a few more question's..
For some reason my icon doesn't show for my minimap button, it's just a clear button, and i also can't get it to stay in the spot the user move's it to. It always goes back to the top left of the minimap.
that's a combo between how you save the frame position and what you code looks like.
IMO ditch the minimap icon and go for LDB plugin instead. Much simpler and nicer to everyone else :) and you can still have you minimap button via libdbicon
Is a hold over from my example, that is a hold over from something previous, your suggestion is better. It also allows for when your in group and someone else loots :) --Edit: you may want to also check for nil values if you only grab the part in the ( )
@OP all you need is this line to simply your math, lua is smart :)