DarkmoonQuestItems addon

When i got a Darkmoon Faire quest item and i completed the quest, i always took a screenshot of the item, so i don’t forget which item it was.
It was a little annoying so i decided to create an addon that shows me which quest i completed.

I just wanted share it with you guys, maybe you’ll need it too. :slight_smile:
I uploaded it to curseforge, you can download it here: https://wow.curseforge.com/projects/darkmoonquestitems

Hi, i just saw in your project notes that it outputs the item links in English and that the user needs to click the link to see the name in their client’s language. Which i think isn’t very language friendly.

Instead, I’d like to advise you to use the item IDs instead, and then use the GetItemInfo API to retrieve that item’s localized name. That way you can use the localized name as display for the item links in the chat window which resolves this issue.

Documentation on the GetItemInfo API can be found here: https://wow.gamepedia.com/API_GetItemInfo

I used it before but i deleted that code. Unfortunately it needs pre-caching. So if you don’t pre-cache the items, it will just return “nil” value for the item link.
I think it’s a faster and easier method to store the item links manually.

I will translate later the item names to other client languages, it’s really easy because all item names are on wowhead. It takes just time to collect all names. :smile:
So if i’ll have a little time, i’ll do it.

Yeah, the items do indeed need pre-caching. I’ve also just had a look at the code (which is very neatly organized btw, you have good coding manners. :smiley:) to see if this is something that could be easily implemented.

I would personally opt to hook onto the PLAYER_ENTERING_WORLD event which fires when the client has loaded, then retrieve the information for each item in your tables and replace the itemName field with the localized values you’ve retrieved at load. Perhaps add a field isLocalized to keep track of the items that haven’t been loaded yet because of GetItemInfo's asynchronous nature.

Gimme a few min, i’ll edit the code on my local copy to provide a sample which can gracefully localize item names. Doing this programmatically would be beneficial to prevent labor when a new language is added or an item’s name changed.

Thanks. :slight_smile:

Yeah, actually that would maybe better, but i don’t think that Blizzard will add a new language (they are too lazy for that :smile:). I choose the lazier way and just write them manually in a lua file. :smiley: It’s just a hobby project.

Portugese was only added 1-2 years back i believe, so new languages can definitely happen.

I’ve gone ahead and added this feature to the code. Here’s the edited lua file which gracefully loads the localized names at load:

--[[
### Author: Weper ###
### Version: 1.0
]]--

local QuestItems = {
	["DungeonQuestItems"] = {
		{["itemName"] = "A Treatise on Strategy", ["itemID"] = 71715, ["questID"] = 29451, ["tickets"] = 10},
		{["itemName"] = "Imbued Crystal", ["itemID"] = 71635, ["questID"] = 29443, ["tickets"] = 10},
		{["itemName"] = "Monstrous Egg", ["itemID"] = 71636, ["questID"] = 29444, ["tickets"] = 10},
		{["itemName"] = "Mysterious Grimoire", ["itemID"] = 71637, ["questID"] = 29445, ["tickets"] = 10},
		{["itemName"] = "Ornate Weapon", ["itemID"] = 71638, ["questID"] = 29446, ["tickets"] = 10},
	},

	["battlegroundQuestItems"] = {
		{["itemName"] = "Banner of the Fallen", ["itemID"] = 71951, ["questID"] = 29456, ["tickets"] = 5},
		{["itemName"] = "Captured Insignia", ["itemID"] = 71952, ["questID"] = 29457, ["tickets"] = 5},
		{["itemName"] = "Fallen Adventurer's Journal", ["itemID"] = 71953, ["questID"] = 29458, ["tickets"] = 5},
	},

	["raidQuestItems"] = {
		{["itemName"] = "Soothsayer's Runes", ["itemID"] = 71716, ["questID"] = 29464, ["tickets"] = 15},
	},

	["otherQuestItems"] = {
		{["itemName"] = "Moonfang's Pelt", ["itemID"] = 105891, ["questID"] = 33354, ["tickets"] = 10},
	}
}

--Code to gracefully localize item names
local localizationTicker;

local function loadLocalizedItemNames(questItemTable)
	for key,subtable in pairs(questItemTable) do
		for i = 1, table.getn(subtable) do
			if (not subtable[i]["isLocalized"]) then
				local itemName = GetItemInfo(subtable[i]["itemID"])
				if (itemName) then
					subtable[i]["itemName"] = itemName
					subtable[i]["isLocalized"] = true
				end
			end
		end
	end
end

local function checkForLocalization(questItemTable)
	local isLocalized = true
	for key,subtable in pairs(questItemTable) do
		for i = 1, table.getn(subtable) do
			if (not subtable[i]["isLocalized"]) then
				isLocalized = false
				break;
			end
		end
	end
	if(isLocalized) then
		localizationTicker:Cancel()
	else
		C_Timer.After(10,checkForLocalization(questItemTable));
	end
end

local loadFrame = CreateFrame("Frame")
loadFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
loadFrame:SetScript("OnEvent",function()
	localizationTicker = C_Timer.NewTicker(1, function()
		loadLocalizedItemNames(QuestItems)
	end)
	C_Timer.After(2,function() checkForLocalization(QuestItems) end)
end)
--end of localization code


SLASH_DQI1 = '/dqi';
local function handler(msg, editbox)
	print("|cFF0070DE-------------------- |cFFFF0000Darkmoon Quest Items |cFF0070DE--------------------")
	---------------------------------- [ Dungeon ] -----------------------------------------------	
	printTitle("Dungeon")
	printQuestItemTable(QuestItems["DungeonQuestItems"])
	---------------------------------- [ Battleground ] -----------------------------------------------
	printTitle("Battleground")
	printQuestItemTable(QuestItems["battlegroundQuestItems"])
	---------------------------------- [ Raid ] -----------------------------------------------
	printTitle("Raid")
	printQuestItemTable(QuestItems["raidQuestItems"])
	---------------------------------- [ Other ] -----------------------------------------------
	printTitle("Other")
	printQuestItemTable(QuestItems["otherQuestItems"])

end
SlashCmdList["DQI"] = handler;

function printTitle(titleName)
	print("|cfffdff00-- |cFF00FFFF" .. titleName .. "|cfffdff00--")
end


function toQuestItemLink (itemName, itemID)
	return "|cff0070dd|Hitem:" .. itemID .. "|h[" .. itemName .. "]|h|r"
end


function printQuestItemInfo (questItemLink, questID, tickets)
	local completed = IsQuestFlaggedCompleted(questID)
	print(questItemLink .. " |cffffaa08- |cff08c7ffReward|cffffffff: |cFFFF0000" .. tickets .. " tickets |cffffaa08- |cff08c7ffCompleted|cffffffff: " .. (completed == true and "|c0000FF00Yes" or "|cFFFF0000No"))
end

function printQuestItemTable(questItemTable)
	for i = 1, table.getn(questItemTable) do
		local itemName = GetItemInfo(questItemTable[i]["itemID"]);
		local questItemLink = toQuestItemLink(itemName, questItemTable[i]["itemID"])
		local questID = questItemTable[i]["questID"]
		local tickets = questItemTable[i]["tickets"]
		printQuestItemInfo(questItemLink, questID, tickets)	
	end
end

I’ve just tested this with german, and item names are now localized:
http://prntscr.com/m4p2ue

The code looks really nice and thanks for helping me, but i prefer to use my own code. :smiley: (Actually i modified already the item names and i created a localized lua file, so i just need to collect the item names for the other languages. Probably i’ll do it tomorrow.)

Edit: The item names are now translated to all languages.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.