1. #1

    Determine gold looted - localization problems

    I have an addon that keeps track of the gold you earned from doing dungeon/raid runs from both direct drops and vendor price, but I've been having multiple reports on Curse of people saying that it only counts the vendor price, not the actual gold dropped by mobs. Other people (and myself) are not experiencing this problem.

    To calculate gold drops, I am using the LOOT_OPENED event:

    Code:
    for i=1, GetNumLootItems() do
    	local _, item, quantity = GetLootSlotInfo(i);
    	if (quantity ~= 0) then
    		--Vendor price calculation
    	else
    		for line in item:gmatch("[^\r\n]+") do
    			local number = 0;
    			local denomination = "";
    			for word in line:gmatch("%w+") do
    				if tonumber(word) ~= nil then
    					number = word;
    				else
    					denomination = word;
    				end
    			end
    			if denomination == 'Gold' then
    				lootedMoney = lootedMoney + (number * 100 * 100);
    			elseif denomination == 'Silver' then
    				lootedMoney = lootedMoney + (number * 100);
    			elseif denomination == 'Copper' then
    				lootedMoney = lootedMoney + number;
    			end
    		end
    	end
    end
    I can't get anybody who reports the bug to respond, but I'm pretty sure the problem stems from my denomination check, if the player using the addon has a language other than English, it will fail.

    Is there an easier way for me to check for gold looted without worrying about localization settings?
    Last edited by Arcilux; 2016-02-26 at 08:53 PM. Reason: formatting
    Author of Instance Profit Tracker
    Find out how much gold you earn soloing raids and dungeons

    Curse | GitHub
    WowInterface

  2. #2
    Code:
    local goldPattern = GOLD_AMOUNT:gsub('%%d', '(%%d*)')
    local silverPattern = SILVER_AMOUNT:gsub('%%d', '(%%d*)')
    local copperPattern = COPPER_AMOUNT:gsub('%%d', '(%%d*)')
    
    
    
    for i=1, GetNumLootItems() do
       local arg1, item, quantity = GetLootSlotInfo(i);
       
       --print('T', arg1, item:gsub("\124", '#'), quanity)
       
       if (quantity ~= 0) then
          --Vendor price calculation
       else
          
          local gold = tonumber(string.match(item, goldPattern) or 0)
          local silver = tonumber(string.match(item, silverPattern) or 0)
          local copper = tonumber(string.match(item, copperPattern) or 0)
          
          print('T', gold, silver, copper)
          
       end
    end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •