That's because with this line of code your doubling it. What you want to do is not double it, but set your SV to it. You might be running into scoping issues if your variable names are all the same.
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.
prolly not..
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 ) )
end
end
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
However if you must with a minimap button, i think this link will help, there is code at the bottom to help.
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 :)
That the new amount being added might be 0 is unimportant. Lua evaluates expressions right onto left. So you can update a variable while adding the previous value of that variable to it.
local GOLD = GOLD_AMOUNT:gsub("%%d", "%(%%d+%)")
local SILVER = SILVER_AMOUNT:gsub("%%d", "%(%%d+%)")
local COPPER = COPPER_AMOUNT:gsub("%%d", "%(%%d+%)")
function addon:CHAT_MSG_MONEY(event, msg, ...)
local _, guild = msg:match( "(.+)%((.+)%)" )
local gold = guild:match(GOLD) or 0
local silver = guild:match(SILVER) or 0
local copper = guild:match(COPPER) or 0
local total = (gold*1000) + (silver*100) + copper
print( GetCoinTextureString( total ) )
end
I'm leery of doing something of this manner: Then people will start asking to track money spent on flightmasters, repairs, etc...and this suddenly turns into a competitor for Auditor.
@ your database synch methods, using time() is not useful. [[ date("!%Y%m%d%H%M") ]] was a more effective way of tracking time with guilds in several timezones. Also looking over your scanning method for the guild bank brings back memories from when i wrote the link scanning code for GuildCraft... tis a mess of a problem.
On your Comms function. separate it out. I did something like this for GuildCraft.. granted i didn't use LibCompress because it wasn't needed.
IE:
[php]
local function HandleComms(distro, sender, success, command, ...)
if success and lib[command] then
lib[command](lib, command, distro, sender, ...)
--- This format of calling the function just keeps things consistant
--- with how the WoW Event handler & CBH works. "command" basically
--- is the event in this case :)
end
end
function lib:OnCommReceived(prefix, msg, distro, sender)
if prefix == "LGB" then
local data, err = LibCompress:Decompress(msg)
if not err then
HandleComms(distro, sender, lib:Deserialize(data) )
end
end
end
[/php]
You can also create helper functions like this:
[php]
function lib:SendGuildMessage(distro, target, command, ...)
local data = self:Serialize(command, ...)
local compressed = LibCompress:Compress(data)
self:SendAddonMessage(addon_prefix, data, distro, target)
---- ^^ This is the Ace3Comms function
end
[/php]
These sort of functions help with the replication of code in various places. This allows you to throw data around clients consistently. You don't have to worry about 3 functions that send data doing it differently.
------
On methodology, i would stop caring about a player's rank and what parts of the guild bank they can see. There is a lot of backwards event logic behind this idea mostly due to how WoW handles these things. I would just give up on it and only filter stuff when you actually go to use the data if anything.
0
That's because with this line of code your doubling it. What you want to do is not double it, but set your SV to it. You might be running into scoping issues if your variable names are all the same.
0
Why would event equal one thing and then, with nothing changed, equal something else on the next line of code?
0
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.
0
never used javascript actually
0
prolly not..
oh yes, you can mix logic and math together like that :)
0
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
However if you must with a minimap button, i think this link will help, there is code at the bottom to help.
0
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 :)
That the new amount being added might be 0 is unimportant. Lua evaluates expressions right onto left. So you can update a variable while adding the previous value of that variable to it.
0
9/10 things in the chat box is an event, in this case the event "CHAT_MSG_MONEY"
0
Sure, for testing you can. but considered bad form if you leave it in.
0
0
True. Will have to write my own
0
0
0
0
IE:
[php]
local function HandleComms(distro, sender, success, command, ...)
if success and lib[command] then
lib[command](lib, command, distro, sender, ...)
--- This format of calling the function just keeps things consistant
--- with how the WoW Event handler & CBH works. "command" basically
--- is the event in this case :)
end
end
function lib:OnCommReceived(prefix, msg, distro, sender)
if prefix == "LGB" then
local data, err = LibCompress:Decompress(msg)
if not err then
HandleComms(distro, sender, lib:Deserialize(data) )
end
end
end
[/php]
You can also create helper functions like this:
[php]
function lib:SendGuildMessage(distro, target, command, ...)
local data = self:Serialize(command, ...)
local compressed = LibCompress:Compress(data)
self:SendAddonMessage(addon_prefix, data, distro, target)
---- ^^ This is the Ace3Comms function
end
[/php]
These sort of functions help with the replication of code in various places. This allows you to throw data around clients consistently. You don't have to worry about 3 functions that send data doing it differently.
------
On methodology, i would stop caring about a player's rank and what parts of the guild bank they can see. There is a lot of backwards event logic behind this idea mostly due to how WoW handles these things. I would just give up on it and only filter stuff when you actually go to use the data if anything.