Thread Tools Display Modes
Prev Previous Post   Next Post Next
02/25/15, 12:14 PM   #1
xTG
AddOn Author - Click to view addons
Join Date: Feb 2015
Posts: 14
Problem with reading guild bank content

Hello there,

i'm having issue with reading the guild bank content.
Sometimes it works... Sometimes not... And i don't understand why ! That's make me crazy...

I actually launch my code on two events.
EVENT_GUILD_BANK_SELECTED
This simply set a global variable to get the bankID.
Code:
function LGBE:selectGuildBank(eventCode, guildBankId)
	LGBEStack.guildBankId = guildBankId
	logActionToChat(string.format("Banque de guilde active : (%d) %s", LGBEStack.guildBankId, GetGuildName(LGBEStack.guildBankId)))
end
EVENT_GUILD_BANK_ITEMS_READY
Here is the main point.
In my trace i see the bankID is correct.
But it seems the GetItemName, GetItemType only return something the first time i launch this function...
Code:
function LGBE:update()
	if LGBEStack.debugInfo ~= false then
		logActionToChat("LGBE:update")
	end
	if LGBEStack.exporting ~= true then
		LGBEStack.debugInfo = true
		local bankSlots = GetBagSize(BAG_GUILDBANK)
		local nbItems = 0
		local nbNonStackedSlot = 0

		if LGBEStack.debugInfo ~= false then
			logActionToChat(string.format("bankSlots=(%d)", bankSlots))
		end
		logActionToChat("LegionGuildBankExtract : Extraction en cours...")
		logActionToChat(string.format("Banque de guilde active : (%d) %s", LGBEStack.guildBankId, GetGuildName(LGBEStack.guildBankId)))
		
		-- réinitialisation des variables sauvegardées
		savedVars['bank'] = {}
		
		--
		-- Boucler sur les slots de la banque
		--
		for bankSlot = 0, bankSlots do
			local bankItemName = GetItemName(BAG_GUILDBANK, bankSlot)
			local bankStack,bankMaxStack = GetSlotStackSize(BAG_GUILDBANK, bankSlot)
			local bankItemType = GetItemType(BAG_GUILDBANK, bankSlot)
			if bankSlot < 50 then
				logActionToChat(string.format("Slot %d %s %d %d %d", bankSlot, bankItemName, bankStack, bankMaxStack, bankItemType))
			end
			if bankItemName ~= "" then
				-- Slot non vide, on sauvegarde donc l'information
				local itemType = GetItemType(BAG_GUILDBANK, bankSlot)
				if isSavedItem[itemType + 1] ~= false then -- /!\ les types commencent à 0 mais les index d'array à 1
					if savedVars['bank'][bankItemName] ~= nil then
						-- L'objet a déjà été inséré via une autre pile, on remet juste à jour le nombre
						savedVars['bank'][bankItemName]['bankStack'] = savedVars['bank'][bankItemName]['bankStack'] + bankStack
						if LGBEStack.debugInfo ~= false then
							logActionToChat(string.format("Slot(%s) %s/%s %s additionnés", bankSlot, bankStack, bankMaxStack, bankItemName))
						end
						if bankStack < bankMaxStack and savedVars['bank'][bankItemName]['bankStack'] < bankMaxStack then
							nbNonStackedSlot = nbNonStackedSlot + 1
						end
					else
						local tmpArray = {}
						tmpArray['bankSlot'] = bankSlot
						tmpArray['bankStack'] = bankStack
						tmpArray['bankItemName'] = bankItemName
						savedVars['bank'][bankItemName] = tmpArray
						if LGBEStack.debugInfo ~= false then
							logActionToChat(string.format("Slot(%s) %s %s ajoutés", bankSlot, bankStack, bankItemName))
						end
					end
					nbItems = nbItems + 1
				end
			end
		end
		logActionToChat(string.format("LegionGuildBankExtract : Fin [%d objets extraits][%d piles séparées]", nbItems, nbNonStackedSlot))
		-- Mise a jour de la banque sauvegardée pour ne pas exécuter le script plusieurs fois
		if nbItems ~= 0 then
			LGBEStack.lastGuildBankIdExport = LGBEStack.guildBankId
		end
		LGBEStack.debugInfo = false
	else
		if LGBEStack.debugInfo ~= false then
			logActionToChat("Export deja en cours")
		end
	end
end
If i try to launch this function on the second or third guild bank it returns 0 items and i can see the 50 first slots empty. Which are not...

Anyone have a clue about this ? What i am doing wrong ?

Best Regards.
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Problem with reading guild bank content


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