0
+local defaults = {macro = "#showtooltip\n%MACRO%"}
0
local ids, bests, allitems, items, dirty = LibStub("tekIDmemo"), {}, {}, {
0
bandage = "2581:114,8545:1104,21991:3400,14530:2000,6451:640,3531:301,1251:66,8544:800,21990:2800,14529:1360,6450:400,3530:161",
0
hstone = "14894:600,25881:400,23329:24,25883:1250,25880:180,15723:1400,11951:800,25882:640,25498:96,11952:425,11951:800,5509:500,5510:800,5511:250,5512:100,9421:1200,19004:110,19005:120,19006:275,19007:300,19008:550,19009:600,19010:880,19011:960,19012:1320,19013:1440,22103:2080,22104:2288,22105:2496",
0
@@ -14,6 +19,10 @@ local ids, bests, allitems, items, dirty = LibStub("tekIDmemo"), {}, {}, {
0
+------------------------------
0
+------------------------------
0
local function TableStuffer(...)
0
for i=1,select("#", ...) do
0
for i,v in pairs(items) do bests[i], items[i] = {}, TableStuffer(string.split(" ,", v)) end
0
-local function edit(name, food, pot, stone, shift)
0
- local macroid = GetMacroIndexByName(name)
0
- if not macroid then return end
0
+-----------------------------
0
+-----------------------------
0
- local body = "#showtooltip\n/use "
0
- if shift then body = body .. "[mod:shift,target=player] item:"..shift.."; " end
0
- if (pot and not stone) or (stone and not pot) then body = body .. "[combat] item:"..(pot or stone).."; " end
0
- body = body .. (pot and stone and "[nocombat] " or "").."item:"..(food or "6948")
0
+Buffet = CreateFrame("frame")
0
+Buffet:SetScript("OnEvent", function(self, event, ...) if self[event] then return self[event](self, event, ...) end end)
0
+Buffet:RegisterEvent("ADDON_LOADED")
0
+function Buffet:Print(...) ChatFrame1:AddMessage(string.join(" ", "|cFF33FF99Buffet|r:", ...)) end
0
+function Buffet:ADDON_LOADED(event, addon)
0
+ if addon ~= "Buffet" then return end
0
+ BuffetDB = setmetatable(BuffetDB or {}, {__index = defaults})
0
+ self:UnregisterEvent("ADDON_LOADED")
0
+ self.ADDON_LOADED = nil
0
+ if IsLoggedIn() then self:PLAYER_LOGIN() else self:RegisterEvent("PLAYER_LOGIN") end
0
+function Buffet:PLAYER_LOGIN()
0
+ self:RegisterEvent("PLAYER_LOGOUT")
0
+ self:RegisterEvent("PLAYER_REGEN_ENABLED")
0
+ self:RegisterEvent("BAG_UPDATE")
0
+ self:RegisterEvent("PLAYER_LEVEL_UP")
0
+ self:UnregisterEvent("PLAYER_LOGIN")
0
+ self.PLAYER_LOGIN = nil
0
+function Buffet:PLAYER_LOGOUT()
0
+ for i,v in pairs(defaults) do if self.db[i] == v then self.db[i] = nil end end
0
- if pot and stone then body = body .. "\n/castsequence [combat,nomod] reset=combat item:"..stone..", item:"..pot end
0
- EditMacro(macroid, name, 1, body, 1)
0
+function Buffet:PLAYER_REGEN_ENABLED()
0
+ if dirty then self:Scan() end
0
+function Buffet:BAG_UPDATE()
0
+ if not InCombatLockdown() then self:Scan() end
0
+Buffet.PLAYER_LEVEL_UP = Buffet.BAG_UPDATE
0
for _,t in pairs(bests) do for i in pairs(t) do t[i] = nil end end
0
local mylevel = UnitLevel("player")
0
@@ -62,22 +110,24 @@ local function scan()
0
- edit("AutoHP", bests.conjfood.id or bests.percfood.id or bests.food.id or bests.hstone.id or bests.hppot.id, bests.hppot.id, bests.hstone.id, bests.bandage.id)
0
- edit("AutoMP", bests.conjwater.id or bests.percwater.id or bests.water.id or bests.mstone.id or bests.mppot.id, bests.mppot.id, bests.mstone.id)
0
+ self:Edit("AutoHP", bests.conjfood.id or bests.percfood.id or bests.food.id or bests.hstone.id or bests.hppot.id, bests.hppot.id, bests.hstone.id, bests.bandage.id)
0
+ self:Edit("AutoMP", bests.conjwater.id or bests.percwater.id or bests.water.id or bests.mstone.id or bests.mppot.id, bests.mppot.id, bests.mstone.id)
0
-local f = CreateFrame("Frame")
0
-f:SetScript("OnEvent", function(self, event, ...)
0
- if event ~= "PLAYER_REGEN_ENABLED" then dirty = true end
0
- if dirty and not InCombatLockdown() then scan() end
0
-f:RegisterEvent("PLAYER_LOGIN")
0
-f:RegisterEvent("PLAYER_REGEN_ENABLED")
0
-f:RegisterEvent("BAG_UPDATE")
0
-f:RegisterEvent("PLAYER_LEVEL_UP")
0
+function Buffet:Edit(name, food, pot, stone, shift)
0
+ local macroid = GetMacroIndexByName(name)
0
+ if not macroid then return end
0
+ if shift then body = body .. "[mod:shift,target=player] item:"..shift.."; " end
0
+ if (pot and not stone) or (stone and not pot) then body = body .. "[combat] item:"..(pot or stone).."; " end
0
+ body = body .. (pot and stone and "[nocombat] " or "").."item:"..(food or "6948")
0
+ if pot and stone then body = body .. "\n/castsequence [combat,nomod] reset=combat item:"..stone..", item:"..pot end
0
+ EditMacro(macroid, name, 1, self.db.macro:gsub("%%MACRO%%", body), 1)
Comments
No one has commented yet.