From e77a8136366dfb1e946732e03bbd0691cf594aa7 Mon Sep 17 00:00:00 2001 From: torhal Date: Sat, 6 Feb 2010 06:35:00 +0000 Subject: [PATCH] Added addon:DumpRecipe() - used for single recipes, by spellID. --- Datamine.lua | 119 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 66 insertions(+), 53 deletions(-) diff --git a/Datamine.lua b/Datamine.lua index f47c013..63518e7 100644 --- a/Datamine.lua +++ b/Datamine.lua @@ -1475,6 +1475,64 @@ do end table.sort(sorted_recipes, Sort_AscID) end + local NUM_FILTER_FLAGS = 128 + + local function RecipeDump(id, single) + local data = private.recipe_list[id or 1] + + if single and not data then + addon:Print("Invalid recipe ID.") + return + end + local flag_string + local specialty = not data.specialty and "" or (", "..data.specialty) + tinsert(output, string.format("-- %s -- %d", data.name, data.spell_id)) + tinsert(output, string.format("AddRecipe(%d, %d, %s, %s, %s, %d, %d, %d, %d%s)", + data.spell_id, data.skill_level, tostring(data.item_id), RARITY_STRINGS[data.quality], VERSION_STRINGS[tostring(data.genesis)], + data.optimal_level, data.medium_level, data.easy_level, data.trivial_level, specialty)) + + for i = 1, NUM_FILTER_FLAGS, 1 do + if data.Flags[i] then + if not flag_string then + flag_string = "F."..FILTER_STRINGS[i] + else + flag_string = flag_string..", ".."F."..FILTER_STRINGS[i] + end + end + end + tinsert(output, string.format("self:addTradeFlags(RecipeDB, %d, %s)", data.spell_id, flag_string)) + + flag_string = nil + + for index, acquire in ipairs(data.Acquire) do + local acquire_type = acquire.type + + if acquire_type == ACQUIRE_TYPES.REPUTATION then + local faction_string = FACTION_NAMES[acquire.ID] + + if not faction_string then + faction_string = acquire.ID + addon:Printf("Recipe %d (%s) - no string for faction %d", data.spell_id, data.name, acquire.ID) + else + faction_string = "FAC."..faction_string + end + + if not flag_string then + flag_string = "A."..ACQUIRE_STRINGS[acquire.type]..", "..faction_string..", ".."REP."..REP_LEVELS[acquire.rep_level or 1]..", "..acquire.rep_vendor + else + flag_string = flag_string..", ".."A."..ACQUIRE_STRINGS[acquire.type]..", "..faction_string..", ".."REP."..REP_LEVELS[acquire.rep_level or 1]..", "..acquire.rep_vendor + end + else + if not flag_string then + flag_string = "A."..ACQUIRE_STRINGS[acquire.type]..", "..acquire.ID + else + flag_string = flag_string..", ".."A."..ACQUIRE_STRINGS[acquire.type]..", "..acquire.ID + end + end + end + tinsert(output, string.format("self:addTradeAcquire(RecipeDB, %d, %s)", data.spell_id, flag_string)) + tinsert(output, "") + end local function ProfessionDump(prof_name) local master_list = LoadRecipe() @@ -1493,65 +1551,20 @@ do end end SortRecipeList() - - local NUM_FILTER_FLAGS = 128 - twipe(output) - for index, name in ipairs(addon.sorted_recipes) do - local data = private.recipe_list[name] - local flag_string - local specialty = not data.specialty and "" or (", "..data.specialty) - tinsert(output, string.format("-- %s -- %d", data.name, data.spell_id)) - tinsert(output, string.format("AddRecipe(%d, %d, %s, %s, %s, %d, %d, %d, %d%s)", - data.spell_id, data.skill_level, tostring(data.item_id), RARITY_STRINGS[data.quality], VERSION_STRINGS[tostring(data.genesis)], - data.optimal_level, data.medium_level, data.easy_level, data.trivial_level, specialty)) - - for i = 1, NUM_FILTER_FLAGS, 1 do - if data.Flags[i] then - if not flag_string then - flag_string = "F."..FILTER_STRINGS[i] - else - flag_string = flag_string..", ".."F."..FILTER_STRINGS[i] - end - end - end - tinsert(output, string.format("self:addTradeFlags(RecipeDB, %d, %s)", data.spell_id, flag_string)) - - flag_string = nil - - for index, acquire in ipairs(data.Acquire) do - local acquire_type = acquire.type - - if acquire_type == ACQUIRE_TYPES.REPUTATION then - local faction_string = FACTION_NAMES[acquire.ID] - - if not faction_string then - faction_string = acquire.ID - addon:Printf("Recipe %d (%s) - no string for faction %d", data.spell_id, data.name, acquire.ID) - else - faction_string = "FAC."..faction_string - end - - if not flag_string then - flag_string = "A."..ACQUIRE_STRINGS[acquire.type]..", "..faction_string..", ".."REP."..REP_LEVELS[acquire.rep_level or 1]..", "..acquire.rep_vendor - else - flag_string = flag_string..", ".."A."..ACQUIRE_STRINGS[acquire.type]..", "..faction_string..", ".."REP."..REP_LEVELS[acquire.rep_level or 1]..", "..acquire.rep_vendor - end - else - if not flag_string then - flag_string = "A."..ACQUIRE_STRINGS[acquire.type]..", "..acquire.ID - else - flag_string = flag_string..", ".."A."..ACQUIRE_STRINGS[acquire.type]..", "..acquire.ID - end - end - end - tinsert(output, string.format("self:addTradeAcquire(RecipeDB, %d, %s)", data.spell_id, flag_string)) - tinsert(output, "") + for index, id in ipairs(addon.sorted_recipes) do + RecipeDump(id, false) end addon:DisplayTextDump(nil, nil, tconcat(output, "\n")) end + function addon:DumpRecipe(id_num) + twipe(output) + RecipeDump(id_num, true) + addon:DisplayTextDump(nil, nil, tconcat(output, "\n")) + end + function addon:DumpProfession(prof_name) if type(prof_name) == "number" then prof_name = GetSpellInfo(prof_name) -- 1.7.9.5