Aaron@0: local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit") Aaron@0: local GatherMate = LibStub("AceAddon-3.0"):GetAddon("GatherMate") Aaron@0: local tabletest = {} Aaron@0: local db = {} Aaron@0: RecipeProfit.db = db; Aaron@0: Aaron@0: function debugprint(val, indent) Aaron@0: indent = indent or ""; Aaron@0: if not(type(val) == "table") then Aaron@0: print("Not table: " .. val) Aaron@0: return Aaron@0: end Aaron@0: Aaron@0: for k,v in pairs(val) do Aaron@0: if(type(k) == "table" and type(v) == "table") then Aaron@0: print(indent .. "table key: {") Aaron@0: debugprint(k, indent .. " ") Aaron@0: print(indent .. "} = {") Aaron@0: debugprint(v, indent .. " ") Aaron@0: print(indent .. "}") Aaron@0: elseif(type(v) == "table") then Aaron@0: print(indent .. k .. " = {") Aaron@0: debugprint(v, indent .. " ") Aaron@0: print(indent .. "}") Aaron@0: else Aaron@0: print(indent .. k .. " = " .. v) Aaron@0: end Aaron@0: end Aaron@0: end Aaron@0: Aaron@0: local options = { Aaron@0: type = "group", Aaron@0: name = "RecipeProfit", -- addon name to import from, don't localize Aaron@0: handler = {}, Aaron@0: disabled = false, Aaron@0: args = { Aaron@0: faction = { Aaron@0: order = 1, Aaron@0: name = "Select Database", Aaron@0: desc = "Show a different database", Aaron@0: type = "group", Aaron@0: guiInline = true, Aaron@0: args = { Aaron@0: faction = { Aaron@0: order = 0, Aaron@0: name = "Faction", Aaron@0: desc = "Show a different database.", Aaron@0: type = "select", Aaron@0: values = { Aaron@0: ["Alliance"] = "Alliance", Aaron@0: ["Horde"] = "Horde", Aaron@0: ["default"] = "Default (Determined By Character)", Aaron@0: }, Aaron@0: arg = "faction", Aaron@0: }, Aaron@0: }, Aaron@0: get = function(k) print(k); return db.profile[k.arg]; end, Aaron@0: set = function(k, v) db.profile[k.arg] = v; RecipeProfit:DoMerge(); end, Aaron@0: }, Aaron@0: loadData = { Aaron@0: order = 8, Aaron@0: name = "Import Data", Aaron@0: desc = "Load RecipeProfit and import the data to your database.", Aaron@0: type = "execute", Aaron@0: func = function() Aaron@0: RecipeProfit:DoMerge() Aaron@0: end Aaron@0: }, Aaron@0: } Aaron@0: } Aaron@0: Aaron@0: local defaults = { Aaron@0: faction = nil, Aaron@0: } Aaron@0: Aaron@0: function RecipeProfit:OnInitialize() Aaron@0: profile = profile or defaults Aaron@0: db.profile = profile Aaron@0: db.storage = {} Aaron@0: Aaron@0: GatherMate:GetModule("Config"):RegisterModule("RecipeProfit", options) Aaron@0: GatherMate:RegisterDBType("RecipeProfit", db.storage) Aaron@0: GatherMate.db.profile.show["RecipeProfit"] = "always" Aaron@0: GatherMate.nodeIDs["RecipeProfit"] = {} Aaron@0: GatherMate.nodeTextures["RecipeProfit"] = {} Aaron@0: GatherMate.nodeMinHarvest["RecipeProfit"] = {} Aaron@0: nodes = GatherMate.nodeIDs["RecipeProfit"] Aaron@0: Aaron@0: for id, note in pairs(RECIPEPROFIT_alliance) do Aaron@0: nodes[note.item.." - ("..note.vendor.." A)"] = id * 10 Aaron@0: GatherMate.nodeTextures["RecipeProfit"][id * 10] = "Interface\\Icons\\INV_Scroll_05" Aaron@0: end Aaron@0: Aaron@0: for id, note in pairs(RECIPEPROFIT_horde) do Aaron@0: nodes[note.item.." - ("..note.vendor.." H)"] = id * 10 + 1 Aaron@0: GatherMate.nodeTextures["RecipeProfit"][id * 10 + 1] = "Interface\\Icons\\INV_Scroll_05" Aaron@0: end Aaron@0: Aaron@0: GatherMate.reverseNodeIDs["RecipeProfit"] = GatherMate:CreateReversedTable(nodes) Aaron@0: GatherMate:GetModule("Config"):UpdateConfig() Aaron@0: Aaron@0: GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged") Aaron@0: end Aaron@0: Aaron@0: function RecipeProfit:OnEnable() Aaron@0: db.profile.faction = db.profile.faction or UnitFactionGroup("player") Aaron@0: Aaron@0: RecipeProfit:DoMerge() Aaron@0: end Aaron@0: Aaron@0: local ids = {} Aaron@0: function findGoodId(x, y) Aaron@0: if ids[x.." "..y] then Aaron@0: return findGoodId(x + .01, y) Aaron@0: end Aaron@0: Aaron@0: ids[x.." "..y] = true Aaron@0: return x, y Aaron@0: end Aaron@0: Aaron@0: function RecipeProfit:DoMerge() Aaron@0: ids = {} Aaron@0: GatherMate:ClearDB("RecipeProfit") Aaron@0: for id, note in pairs(db.profile.faction == "Alliance" and RECIPEPROFIT_alliance or RECIPEPROFIT_horde) do Aaron@0: x, y = findGoodId(note.x, note.y) Aaron@0: GatherMate:AddNode(note.map, x / 100, y / 100, "RecipeProfit", Aaron@0: note.item.." - ("..note.vendor.." ".. (db.profile.faction == "Alliance" and "A" or "H") ..")") Aaron@0: end Aaron@0: Aaron@0: GatherMate:SendMessage("GatherMateDataImport") Aaron@0: GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged") Aaron@0: end