Go to Page... |
Thread Tools | Display Modes |
07-31-14, 06:47 PM | #1 |
[HELP] Addon only works after /reload
Hello friends WowInterface,
I have an addon that is with a small and simple problem, it works normally, but every time I open WoW and go into the game I need to give the command /reload for the addon to work, otherwise it is loaded but not working . Can someone help me? Below is the code ... Lelex.toc Code:
## Interface: 50001 ## Title: Lelex ## Author: Lelex ## SavedVariables: Subtletydb rotacao.lua Code:
Subtlety = {} Subtlety.currentTarget = "" Subtlety.lastTarget = "" function FM_GetSpellNameById(spellId) if (spellId == nil) then return nil end local spellName, rank, _, _, _, _, _, _, _ = GetSpellInfo(spellId) if rank==nil then return spellName elseif string.len(rank)>1 then return spellName.."("..rank..")" end return spellName end local language = GetLocale(); if language == "esMX" then Subtlety.L = { ["Garrote"] = "Garrote", ["Backstab"] = "Puñalada", ["Slice and Dice"] = "Hacer picadillo", ["Eviscerate"] = "Eviscerar", ["Rupture"] = "Ruptura", ["Recuperate"] = "Reponerse", ["Tricks of the Trade"] = "Secretos del oficio", ["Shadow Blades"] = "Paso de las Sombras", ["Hemorrhage"] = "Hemorragia", ["Ambush"] = "Emboscada", ["Vanish"] = "Esfumarse", ["Shadow Dance"] = "Danza de las Sombras", ["Premeditation"] = "Premeditación", ["Redirect"] = "Redirigir", ["Master of Subtlety"] = "Maestro de la sutileza", ["Stealth"] = "Sigilo", ["Generator"] = "Generator" } elseif language == "frFR" then Subtlety.L = { ["Garrote"] = "Garrot", ["Backstab"] = "Attaque sournoise", ["Slice and Dice"] = "Débiter", ["Eviscerate"] = "Eviscération", ["Rupture"] = "Rupture", ["Recuperate"] = "Conversion", ["Tricks of the Trade"] = "Ficelles du métier", ["Shadow Blades"] = "Pas de l'ombre", ["Hemorrhage"] = "Hémorragie", ["Ambush"] = "Embuscade", ["Vanish"] = "Disparition", ["Shadow Dance"] = "Danse de l'ombre", ["Premeditation"] = "Préméditation", ["Redirect"] = "Rediriger", ["Master of Subtlety"] = "Maître de la discrétion", ["Stealth"] = "Camouflage", ["Generator"] = "Generator" } elseif language == "deDE" then Subtlety.L = { ["Garrote"] = "Erdrosseln", ["Backstab"] = "Meucheln", ["Slice and Dice"] = "Zerhäckseln", ["Eviscerate"] = "Ausweiden", ["Rupture"] = "Blutung", ["Recuperate"] = "Gesundung", ["Tricks of the Trade"] = "Schurkenhandel", ["Shadow Blades"] = "Schattenschritt", ["Hemorrhage"] = "Blutsturz", ["Ambush"] = "Hinterhalt", ["Vanish"] = "Verschwinden", ["Shadow Dance"] = "Schattentanz", ["Premeditation"] = "Konzentration", ["Redirect"] = "Umlenken", ["Master of Subtlety"] = "Meister des hinterhältigen Angriffs", ["Stealth"] = "Verstohlenheit", ["Generator"] = "Generator" } elseif language == "ruRU" then Subtlety.L = { ["Garrote"] = "Гаррота", ["Backstab"] = "Удар в спину", ["Slice and Dice"] = "Мясорубка", ["Eviscerate"] = "Потрошение", ["Rupture"] = "Рваная рана", ["Recuperate"] = "Заживление ран", ["Tricks of the Trade"] = "Маленькие хитрости", ["Shadow Blades"] = "Шаг сквозь тень", ["Hemorrhage"] = "Кровоизлияние", ["Ambush"] = "Внезапный удар", ["Vanish"] = "Исчезновение", ["Shadow Dance"] = "Танец теней", ["Premeditation"] = "Умысел", ["Redirect"] = "Смена приоритетов", ["Master of Subtlety"] = "Мастер скрытности", ["Stealth"] = "Незаметность", ["Generator"] = "Generator" } else Subtlety.L = { ["Garrote"] = "Garrote", ["Backstab"] = "Backstab", ["Slice and Dice"] = "Slice and Dice", ["Eviscerate"] = "Eviscerate", ["Rupture"] = "Rupture", ["Recuperate"] = "Recuperate", ["Tricks of the Trade"] = "Tricks of the Trade", ["Shadow Blades"] = "Shadow Blades", ["Hemorrhage"] = "Hemorrhage", ["Ambush"] = "Ambush", ["Vanish"] = "Vanish", ["Shadow Dance"] = "Shadow Dance", ["Premeditation"] = "Premeditation", ["Redirect"] = "Redirect", ["Master of Subtlety"] = "Master of Subtlety", ["Stealth"] = "Stealth", ["Generator"] = "Generator" } end Subtlety.L["Garrote"] = GetSpellInfo(703) Subtlety.L["Slice and Dice"] = GetSpellInfo(5171) Subtlety.L["Backstab"] = GetSpellInfo(53) Subtlety.L["Hemorrhage"] = GetSpellInfo(1752) Subtlety.L["Hemorrhage-Debuff"] = GetSpellInfo(16511) Subtlety.L["Eviscerate"] = GetSpellInfo(2098) Subtlety.L["Rupture"] = GetSpellInfo(1943) Subtlety.L["Recuperate"] = GetSpellInfo(73651) Subtlety.L["Tricks of the Trade"] = GetSpellInfo(57934) Subtlety.L["Shadow Blades"] = GetSpellInfo(121471) Subtlety.L["Shadow Dance"] = GetSpellInfo(51713) Subtlety.L["Ambush"] = GetSpellInfo(8676) Subtlety.L["Premeditation"] = GetSpellInfo(14183) Subtlety.L["Vanish"] = GetSpellInfo(1856) Subtlety.L["Redirect"] = GetSpellInfo(73981) Subtlety.timeSinceLastUpdate = 0 Subtlety.playerName = UnitName("player") Subtlety.textureList = { ["last"] = nil, ["redirect"] = nil, ["current"] = nil, ["next"] = nil, ["misc"] = nil, ["int"] = nil, ["ss"] = nil, } Subtlety.eventFrame = CreateFrame("Frame") Subtlety.eventFrame:SetScript("OnEvent", function(this, event, ...) Subtlety.events[event](...) end) Subtlety.eventFrame:RegisterEvent("ADDON_LOADED") Subtlety.eventFrame:RegisterEvent("PLAYER_LOGIN") Subtlety.eventFrame:RegisterEvent("PLAYER_ALIVE") Subtlety.eventFrame:RegisterEvent("PLAYER_TARGET_CHANGED") Subtlety.eventFrame:RegisterEvent("PLAYER_TALENT_UPDATE") Subtlety.events = {} function Subtlety.events.PLAYER_TALENT_UPDATE() if GetSpecialization() == 3 then Subtlety.displayFrame:Show() else Subtlety.displayFrame:Hide() end end function Subtlety.events.PLAYER_ALIVE() Subtlety.eventFrame:UnregisterEvent("PLAYER_ALIVE") end function Subtlety.events.PLAYER_LOGIN() Subtlety.playerName = UnitName("player"); end function Subtlety.events.ADDON_LOADED(addon) if addon ~= "Lelex" and GetSpecialization() == 3 then return end local _,playerClass = UnitClass("player") if playerClass ~= "ROGUE" then Subtlety.eventFrame:UnregisterEvent("PLAYER_ALIVE") Subtlety.eventFrame:UnregisterEvent("ADDON_LOADED") Subtlety.eventFrame:UnregisterEvent("PLAYER_LOGIN") Subtlety.eventFrame:UnregisterEvent("PLAYER_TARGET_CHANGED") Subtlety.eventFrame:UnregisterEvent("PLAYER_TALENT_UPDATE") return end if not Subtletydb then Subtletydb = {} end if not Subtletydb.scale then Subtletydb.scale = 1 end if not Subtletydb.RupturePoints then Subtletydb.RupturePoints = 5 end if not Subtletydb.RupturePriority then Subtletydb.RupturePriority = 2 end if not Subtletydb.SliceAndDicePoints then Subtletydb.SliceAndDicePoints = 5 end if not Subtletydb.SliceAndDicePriority then Subtletydb.SliceAndDicePriority = 1 end if Subtletydb.locked == nil then Subtletydb.locked = true end if not Subtletydb.x then Subtletydb.x = 100 end if not Subtletydb.y then Subtletydb.y = 100 end if not Subtletydb.SuggestVanish then Subtletydb.SuggestVanish = false end if not Subtletydb.SuggestBackstab then Subtletydb.SuggestBackstab = true end if not Subtletydb.SuggestShadowDance then Subtletydb.SuggestShadowDance = false end if not Subtletydb.SuggestTotT then Subtletydb.SuggestTotT = false end if Subtletydb.range == nil then Subtletydb.range = true end if (Subtletydb.SuggestBackstab == true) then Subtlety.L["Generator"] = Subtlety.L["Hemorrhage"] else Subtlety.L["Generator"] = Subtlety.L["Backstab"] end Subtlety:CreateGUI() Subtlety.displayFrame:SetScale(Subtletydb.scale) Subtlety:CreateOptionFrame() if Subtletydb.locked then Subtlety.displayFrame:SetScript("OnMouseDown", nil) Subtlety.displayFrame:SetScript("OnMouseUp", nil) Subtlety.displayFrame:SetScript("OnDragStop", nil) Subtlety.displayFrame:SetBackdropColor(0, 0, 0, 0) Subtlety.displayFrame:EnableMouse(false) else Subtlety.displayFrame:SetScript("OnMouseDown", function(self) self:StartMoving() end) Subtlety.displayFrame:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end) Subtlety.displayFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) Subtlety.displayFrame:SetBackdropColor(0, 0, 0, .4) Subtlety.displayFrame:EnableMouse(true) end Subtlety.eventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") Subtlety.eventFrame:RegisterEvent("PLAYER_TARGET_CHANGED") if GetSpecialization() == 3 then Subtlety.displayFrame:Show() else Subtlety.displayFrame:Hide() end end function Subtlety.events.COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, ...) end function Subtlety.events.COMBAT_RATING_UPDATE(unit) end function Subtlety.events.PLAYER_TARGET_CHANGED(...) Subtlety.lastTarget = Subtlety.currentTarget Subtlety.currentTarget = UnitGUID("target") if UnitName("target") == nil or UnitIsFriend("player","target") ~= nil or UnitHealth("target") == 0 then Subtlety.displayFrame_last:Hide() Subtlety.displayFrame_current:Hide() Subtlety.displayFrame_next:Hide() Subtlety.displayFrame_misc:Hide() Subtlety.displayFrame_int:Hide() Subtlety.displayFrame_ss:Hide() else Subtlety.displayFrame_last:Show() Subtlety.displayFrame_current:Show() Subtlety.displayFrame_next:Show() Subtlety.displayFrame_misc:Show() Subtlety.displayFrame_int:Show() Subtlety.displayFrame_ss:Show() Subtlety:DecideSpells() end end function Subtlety:CreateGUI() local displayFrame = CreateFrame("Frame","SubtletyDisplayFrame",UIParent) displayFrame:SetFrameStrata("BACKGROUND") displayFrame:SetWidth(300) displayFrame:SetHeight(95) displayFrame:EnableMouse(true) displayFrame:SetMovable(true) displayFrame:SetClampedToScreen(true) displayFrame:SetScript("OnMouseDown", function(self) self:StartMoving() end) displayFrame:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end) displayFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) displayFrame:SetPoint("CENTER",-200,-200) local displayFrame_last = CreateFrame("Frame","$parent_last", SubtletyDisplayFrame) local displayFrame_current = CreateFrame("Frame","$parent_current", SubtletyDisplayFrame) local displayFrame_next = CreateFrame("Frame","$parent_next", SubtletyDisplayFrame) local displayFrame_misc = CreateFrame("Frame","$parent_misc", SubtletyDisplayFrame) local displayFrame_int = CreateFrame("Frame","$parent_int", SubtletyDisplayFrame) local displayFrame_ss = CreateFrame("Frame","$parent_ss", SubtletyDisplayFrame) displayFrame_last:SetWidth(45) displayFrame_current:SetWidth(70) displayFrame_next:SetWidth(45) displayFrame_misc:SetWidth(45) displayFrame_int:SetWidth(45) displayFrame_ss:SetWidth(45) displayFrame_last:SetHeight(45) displayFrame_current:SetHeight(70) displayFrame_next:SetHeight(45) displayFrame_misc:SetHeight(45) displayFrame_int:SetHeight(45) displayFrame_ss:SetHeight(45) displayFrame_current:SetPoint("TOPLEFT", 140, 40) displayFrame_next:SetPoint("TOPLEFT", 150, -10) displayFrame_last:SetPoint("TOPLEFT", 0, -10) displayFrame_misc:SetPoint("TOPLEFT", 0, 40) displayFrame_int:SetPoint("TOPLEFT", 50, 40) displayFrame_ss:SetPoint("TOPLEFT", 50,-10) local t = displayFrame_last:CreateTexture(nil,"BACKGROUND") t:SetTexture(nil) t:SetAllPoints(displayFrame_last) t:SetAlpha(.8) displayFrame_last.texture = t Subtlety.textureList["last"] = t t = displayFrame_current:CreateTexture(nil,"BACKGROUND") t:SetTexture(nil) t:ClearAllPoints() t:SetAllPoints(displayFrame_current) displayFrame_current.texture = t Subtlety.textureList["current"] = t t = displayFrame_misc:CreateTexture(nil,"BACKGROUND") t:SetTexture(nil) t:SetAllPoints(displayFrame_misc) t:SetAlpha(.8) displayFrame_misc.texture = t Subtlety.textureList["misc"] = t t = displayFrame_int:CreateTexture(nil,"BACKGROUND") t:SetTexture(nil) t:SetAllPoints(displayFrame_int) t:SetAlpha(.8) displayFrame_int.texture = t Subtlety.textureList["int"] = t t = displayFrame_next:CreateTexture(nil,"BACKGROUND") t:SetTexture(nil) t:SetAllPoints(displayFrame_next) t:SetAlpha(.8) displayFrame_next.texture = t Subtlety.textureList["next"] = t t = displayFrame_ss:CreateTexture(nil,"BACKGROUND") t:SetTexture(nil) t:SetAllPoints(displayFrame_ss) t:SetAlpha(.8) displayFrame_ss.texture = t Subtlety.textureList["ss"] = t displayFrame:SetScript("OnUpdate", function(this, elapsed) Subtlety:OnUpdate(elapsed) end) local cooldownFrame = CreateFrame("Cooldown","$parent_cooldown", SubtletyDisplayFrame_current) cooldownFrame:SetHeight(70) cooldownFrame:SetWidth(70) cooldownFrame:ClearAllPoints() cooldownFrame:SetPoint("CENTER", displayFrame_current, "CENTER", 0, 0) Subtlety.displayFrame = displayFrame Subtlety.displayFrame_last = displayFrame_last Subtlety.displayFrame_current = displayFrame_current Subtlety.displayFrame_next = displayFrame_next Subtlety.displayFrame_misc = displayFrame_misc Subtlety.displayFrame_int = displayFrame_int Subtlety.displayFrame_ss = displayFrame_ss Subtlety.cooldownFrame = cooldownFrame end function Subtlety:OnUpdate(elapsed) Subtlety.timeSinceLastUpdate = Subtlety.timeSinceLastUpdate + elapsed; Subtlety:DecideSpells() end function Subtlety:Find(t, v, c) if type(t) == "table" and v then v = (c==0 or c==2) and v:lower() or v for k, val in pairs(t) do val = (c==0 or c==2) and val:lower() or val if (c==1 or c==2) and val:find(v) or v == val then return k end end end return nil end function Subtlety:DecideSpells() Subtlety.timeSinceLastUpdate = 0; if UnitName("target") == nil or UnitIsFriend("player","target") ~= nil or UnitHealth("target") == 0 then return end Subtlety.Finisher = { { spell = "Rupture", name = "rupture", priority = Subtletydb.RupturePriority, points = Subtletydb.RupturePoints, energy = 25, expires = '0', }, { spell = "Slice and Dice", name = "slice_and_dice", priority = Subtletydb.SliceAndDicePriority, points = Subtletydb.SliceAndDicePoints, energy = 25, expires = '0', }, } function sort_func(a, b) return a.priority < b.priority; end table.sort(Subtlety.Finisher, sort_func); local guid = UnitGUID("target") local puid = UnitGUID("player") if guid == nil then Subtlety.textureList["last"]:SetTexture(nil) Subtlety.textureList["current"]:SetTexture(nil) Subtlety.textureList["next"]:SetTexture(nil) Subtlety.textureList["misc"]:SetTexture(nil) Subtlety.textureList["int"]:SetTexture(nil) Subtlety.textureList["ss"]:SetTexture(nil) return end local energy = UnitPower("player") local cp = GetComboPoints("player") local currentTime = GetTime() local spell = "" local nextspell = "" local miscspell = "" local intspell = "" local bleeds = 0 local cost = 0 local garrote = 0 local slice_and_dice = 0 local recuperate = 0 local rupture = 0 local premeditation = 0 local hemorrhage = 0 local vanish = 0 local tott = 0 local shadowblades = 0 local shadow_dance = 0 local master_of_subtlety = 0 local serrated_blades = 0 for i = 1, 2, 1 do local name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitBuff("player", Subtlety.L[Subtlety.Finisher[i].spell]) currentTime = GetTime() if name ~= nil then if Subtlety.Finisher[i].name == "slice_and_dice" then Subtlety.Finisher[i]["expires"] = expirationTime - currentTime end end local name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitDebuff("target", Subtlety.L[Subtlety.Finisher[i].spell]) currentTime = GetTime() if name ~= nil then if Subtlety.Finisher[i].name == "rupture" then Subtlety.Finisher[i]["expires"] = expirationTime - currentTime end end end local name, rank, icon, price, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(Subtlety.L["Generator"]) if name ~= nil then cost = price end local name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitDebuff("target", Subtlety.L["Rupture"]) currentTime = GetTime() if name ~= nil and isMine == "player" then rupture = expirationTime - currentTime end local name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitDebuff("target", Subtlety.L["Garrote"]) currentTime = GetTime() if name ~= nil and isMine == "player" then garrote = expirationTime - currentTime bleeds = 1 end local name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitBuff("player", Subtlety.L["Master of Subtlety"]) currentTime = GetTime() if name ~= nil then master_of_subtlety = expirationTime - currentTime end local name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitDebuff("target", Subtlety.L["Hemorrhage-Debuff"]) currentTime = GetTime() if name ~= nil and isMine == "player" then hemorrhage = expirationTime - currentTime end local start, duration, enabled = GetSpellCooldown(Subtlety.L["Tricks of the Trade"]); if duration ~= nil then tott = duration + start - currentTime else tott = 60 end local start, duration, enabled = GetSpellCooldown(Subtlety.L["Shadow Blades"]); if duration ~= nil then shadowblades = duration + start - currentTime else shadowblades = 60 end local start, duration, enabled = GetSpellCooldown(Subtlety.L["Vanish"]); if duration ~= nil then vanish = duration + start - currentTime else vanish = 60 end local start, duration, enabled = GetSpellCooldown(Subtlety.L["Shadow Dance"]); if duration ~= nil then shadow_dance = duration + start - currentTime else shadow_dance = 60 end if (UnitAura("player", Subtlety.L["Stealth"]) ~= nil or UnitBuff("player", Subtlety.L["Shadow Dance"]) ~= nil or UnitBuff("player", Subtlety.L["Vanish"]) ~= nil) then if UnitAura("player", Subtlety.L["Stealth"]) ~= nil then spell = Subtlety.L["Ambush"]; elseif (tott < 1) and (Subtletydb.SuggestTotT == true) then spell = Subtlety.L["Tricks of the Trade"]; elseif (tonumber(Subtlety.Finisher[1].expires) <= 1) and (cp >= tonumber(Subtlety.Finisher[1].points)) and (tonumber(Subtlety.Finisher[1].points) ~= 0) then if (energy >= Subtlety.Finisher[1].energy) then spell = Subtlety.L[Subtlety.Finisher[1].spell]; else nextspell = Subtlety.L[Subtlety.Finisher[1].spell]; end elseif (tonumber(Subtlety.Finisher[2].expires) <= 1) and (cp >= tonumber(Subtlety.Finisher[2].points)) and (tonumber(Subtlety.Finisher[2].points) ~= 0) then if (energy >= Subtlety.Finisher[2].energy) then spell = Subtlety.L[Subtlety.Finisher[2].spell]; else nextspell = Subtlety.L[Subtlety.Finisher[2].spell]; end elseif (cp == 5) then if (energy >= 25) then spell = Subtlety.L["Eviscerate"]; else nextspell = Subtlety.L["Eviscerate"]; end else if rupture == 0 then if (energy >= 50) then spell = Subtlety.L["Ambush"]; else nextspell = Subtlety.L["Ambush"]; end else if (energy >= 40) then spell = Subtlety.L["Ambush"]; else nextspell = Subtlety.L["Ambush"]; end end end end if (UnitAura("player", Subtlety.L["Stealth"]) == nil and UnitBuff("player", Subtlety.L["Shadow Dance"]) == nil and UnitBuff("player", Subtlety.L["Vanish"]) == nil) then if (rupture <= 5) and (cp == 5) and (rupture ~= 0) then if (energy >= 35) then spell = Subtlety.L["Eviscerate"]; else nextspell = Subtlety.L["Eviscerate"]; end elseif (tott < 1) and (Subtletydb.SuggestTotT == true) then spell = Subtlety.L["Tricks of the Trade"]; elseif (shadow_dance < 1) and (Subtletydb.SuggestShadowDance == true) then spell = Subtlety.L["Shadow Dance"]; elseif (vanish < 1) and (Subtletydb.SuggestVanish == true) and UnitAffectingCombat("player") == 1 then spell = Subtlety.L["Vanish"]; elseif (tonumber(Subtlety.Finisher[1].expires) <= 5) and (cp >= tonumber(Subtlety.Finisher[1].points)) and (tonumber(Subtlety.Finisher[1].points) ~= 0) then if (energy >= Subtlety.Finisher[1].energy) then spell = Subtlety.L[Subtlety.Finisher[1].spell]; else nextspell = Subtlety.L[Subtlety.Finisher[1].spell]; end elseif (tonumber(Subtlety.Finisher[2].expires) <= 5) and (cp >= tonumber(Subtlety.Finisher[2].points)) and (tonumber(Subtlety.Finisher[2].points) ~= 0) then if (energy >= Subtlety.Finisher[2].energy) then spell = Subtlety.L[Subtlety.Finisher[2].spell]; else nextspell = Subtlety.L[Subtlety.Finisher[2].spell]; end elseif (cp == 5) then if (energy >= 25) then spell = Subtlety.L["Eviscerate"]; else nextspell = Subtlety.L["Eviscerate"]; end else if (hemorrhage <= 5) then if (energy >= cost) then spell = Subtlety.L["Hemorrhage"]; else nextspell = Subtlety.L["Hemorrhage"]; end else if (energy >= cost) then spell = Subtlety.L["Generator"]; else nextspell = Subtlety.L["Generator"]; end end end end Subtlety.textureList["current"]:SetTexture(GetSpellBookItemTexture(spell)) Subtlety.textureList["next"]:SetTexture(GetSpellBookItemTexture(nextspell)) if shadow_dance < 1 then Subtlety.textureList["last"]:SetTexture(GetSpellBookItemTexture(Subtlety.L["Shadow Dance"])) else Subtlety.textureList["last"]:SetTexture(nil) end if tott < 1 then Subtlety.textureList["misc"]:SetTexture(GetSpellBookItemTexture(Subtlety.L["Tricks of the Trade"])) else Subtlety.textureList["misc"]:SetTexture(nil) end if (vanish < 1) then Subtlety.textureList["int"]:SetTexture(GetSpellBookItemTexture(Subtlety.L["Vanish"])) else Subtlety.textureList["int"]:SetTexture(nil) end if shadowblades < 1 then Subtlety.textureList["ss"]:SetTexture(GetSpellBookItemTexture(Subtlety.L["Shadow Blades"])) else Subtlety.textureList["ss"]:SetTexture(nil) end if spell ~= "" and spell ~= nil then local start, dur = GetSpellCooldown(spell) if dur == 0 or start == nil or dur == nil then Subtlety.cooldownFrame:SetAlpha(0) else Subtlety.cooldownFrame:SetAlpha(1) Subtlety.cooldownFrame:SetCooldown(start, dur) end end end function Subtlety:CreateOptionFrame() local panel = CreateFrame("FRAME", "SubtletyOptions"); panel.name = "Rotação Subterfúgio"; local fstring00 = panel:CreateFontString("SubtletyOptions_string00","OVERLAY","GameFontNormal") fstring00:SetText("Prioridade") fstring00:SetPoint("TOPLEFT", 355, -35) local fstring01 = panel:CreateFontString("SubtletyOptions_string01","OVERLAY","GameFontNormal") fstring01:SetText("Pontos de Combo") fstring01:SetPoint("TOPLEFT", 485, -35) local fstring2 = panel:CreateFontString("SubtletyOptions_string2","OVERLAY","GameFontNormal") fstring2:SetText("Ruptura") fstring2:SetPoint("TOPLEFT", 10, -70) local slider2a = CreateFrame("Slider", "$parent_s2a", panel, "OptionsSliderTemplate") slider2a:SetMinMaxValues(1, 2) slider2a:SetWidth(75) slider2a:SetValue(Subtlety:GetRupturePriority()) slider2a:SetValueStep(1) slider2a:SetScript("OnValueChanged", function(self) Subtlety:SetRupturePriority(self:GetValue()); getglobal(self:GetName() .. "Text"):SetText(self:GetValue()) end) getglobal(slider2a:GetName() .. "Low"):SetText("1") getglobal(slider2a:GetName() .. "High"):SetText("2") getglobal(slider2a:GetName() .. "Text"):SetText(Subtlety:GetRupturePriority()) slider2a:SetPoint("TOPRIGHT", -200, -70) local slider2b = CreateFrame("Slider", "$parent_s2b", panel, "OptionsSliderTemplate") slider2b:SetMinMaxValues(0, 5) slider2b:SetWidth(150) slider2b:SetValue(Subtlety:GetRupturePoints()) slider2b:SetValueStep(1) slider2b:SetScript("OnValueChanged", function(self) Subtlety:SetRupturePoints(self:GetValue()); getglobal(self:GetName() .. "Text"):SetText(self:GetValue()) end) getglobal(slider2b:GetName() .. "Low"):SetText("0") getglobal(slider2b:GetName() .. "High"):SetText("5") getglobal(slider2b:GetName() .. "Text"):SetText(Subtlety:GetRupturePoints()) slider2b:SetPoint("TOPRIGHT", -10, -70) local fstring3 = panel:CreateFontString("SubtletyOptions_string3","OVERLAY","GameFontNormal") fstring3:SetText("Retalhar") fstring3:SetPoint("TOPLEFT", 10, -100) local slider3a = CreateFrame("Slider", "$parent_s3a", panel, "OptionsSliderTemplate") slider3a:SetMinMaxValues(1, 2) slider3a:SetWidth(75) slider3a:SetValue(Subtlety:GetSliceAndDicePriority()) slider3a:SetValueStep(1) slider3a:SetScript("OnValueChanged", function(self) Subtlety:SetSliceAndDicePriority(self:GetValue()); getglobal(self:GetName() .. "Text"):SetText(self:GetValue()) end) getglobal(slider3a:GetName() .. "Low"):SetText("1") getglobal(slider3a:GetName() .. "High"):SetText("2") getglobal(slider3a:GetName() .. "Text"):SetText(Subtlety:GetSliceAndDicePriority()) slider3a:SetPoint("TOPRIGHT", -200, -100) local slider3b = CreateFrame("Slider", "$parent_s3b", panel, "OptionsSliderTemplate") slider3b:SetMinMaxValues(0, 5) slider3b:SetWidth(150) slider3b:SetValue(Subtlety:GetSliceAndDicePoints()) slider3b:SetValueStep(1) slider3b:SetScript("OnValueChanged", function(self) Subtlety:SetSliceAndDicePoints(self:GetValue()); getglobal(self:GetName() .. "Text"):SetText(self:GetValue()) end) getglobal(slider3b:GetName() .. "Low"):SetText("0") getglobal(slider3b:GetName() .. "High"):SetText("5") getglobal(slider3b:GetName() .. "Text"):SetText(Subtlety:GetSliceAndDicePoints()) slider3b:SetPoint("TOPRIGHT", -10, -100) local fstring4 = panel:CreateFontString("SubtletyOptions_string4","OVERLAY","GameFontNormal") fstring4:SetText("Sugerir Sumir na rotação") fstring4:SetPoint("TOPLEFT", 10, -150) local checkbox4 = CreateFrame("CheckButton", "$parent_cb4", panel, "OptionsCheckButtonTemplate") checkbox4:SetWidth(18) checkbox4:SetHeight(18) checkbox4:SetScript("OnClick", function() Subtlety:ToggleVanish() end) checkbox4:SetPoint("TOPRIGHT", -10, -150) checkbox4:SetChecked(Subtlety:GetVanish()) local fstring5 = panel:CreateFontString("SubtletyOptions_string4","OVERLAY","GameFontNormal") fstring5:SetText("Sugerir Hemorragia para gerar Pontos de Combo") fstring5:SetPoint("TOPLEFT", 10, -180) local checkbox5 = CreateFrame("CheckButton", "$parent_cb5", panel, "OptionsCheckButtonTemplate") checkbox5:SetWidth(18) checkbox5:SetHeight(18) checkbox5:SetScript("OnClick", function() Subtlety:ToggleBackstab() end) checkbox5:SetPoint("TOPRIGHT", -10, -180) checkbox5:SetChecked(Subtlety:GetBackstab()) local fstring6 = panel:CreateFontString("SubtletyOptions_string5","OVERLAY","GameFontNormal") fstring6:SetText("Sugerir Dança das Sombras") fstring6:SetPoint("TOPLEFT", 10, -210) local checkbox6 = CreateFrame("CheckButton", "$parent_cb6", panel, "OptionsCheckButtonTemplate") checkbox6:SetWidth(18) checkbox6:SetHeight(18) checkbox6:SetScript("OnClick", function() Subtlety:ToggleShadowDance() end) checkbox6:SetPoint("TOPRIGHT", -10, -210) checkbox6:SetChecked(Subtlety:GetShadowDance()) local fstring7 = panel:CreateFontString("SubtletyOptions_string7","OVERLAY","GameFontNormal") fstring7:SetText("Sugerir Truques do Ofício") fstring7:SetPoint("TOPLEFT", 10, -240) local checkbox7 = CreateFrame("CheckButton", "$parent_cb7", panel, "OptionsCheckButtonTemplate") checkbox7:SetWidth(18) checkbox7:SetHeight(18) checkbox7:SetScript("OnClick", function() Subtlety:ToggleTotT() end) checkbox7:SetPoint("TOPRIGHT", -10, -240) checkbox7:SetChecked(Subtlety:GetTotT()) local fstring8 = panel:CreateFontString("SubtletyOptions_string8","OVERLAY","GameFontNormal") fstring8:SetText("Escala GUI") fstring8:SetPoint("TOPLEFT", 10, -280) local slider8 = CreateFrame("Slider", "$parent_s8", panel, "OptionsSliderTemplate") slider8:SetMinMaxValues(.5, 1.5) slider8:SetValue(Subtlety:GetScale()) slider8:SetValueStep(.05) slider8:SetScript("OnValueChanged", function(self) Subtlety:SetScale(self:GetValue()); getglobal(self:GetName() .. "Text"):SetText(self:GetValue()) end) getglobal(slider8:GetName() .. "Low"):SetText("0.5") getglobal(slider8:GetName() .. "High"):SetText("1.5") getglobal(slider8:GetName() .. "Text"):SetText(Subtlety:GetScale()) slider8:SetPoint("TOPRIGHT", -10, -280) local fstring9 = panel:CreateFontString("SubtletyOptions_string1","OVERLAY","GameFontNormal") fstring9:SetText("Travar") fstring9:SetPoint("TOPLEFT", 10, -320) local checkbox9 = CreateFrame("CheckButton", "$parent_cb9", panel, "OptionsCheckButtonTemplate") checkbox9:SetWidth(18) checkbox9:SetHeight(18) checkbox9:SetScript("OnClick", function() Subtlety:ToggleLocked() end) checkbox9:SetPoint("TOPRIGHT", -10, -320) checkbox9:SetChecked(Subtlety:GetLocked()) InterfaceOptions_AddCategory(panel); end function Subtlety:GetLocked() return Subtletydb.locked end function Subtlety:ToggleLocked() if Subtletydb.locked then Subtletydb.locked = false Subtlety.displayFrame:SetScript("OnMouseDown", function(self) self:StartMoving() end) Subtlety.displayFrame:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end) Subtlety.displayFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) Subtlety.displayFrame:SetBackdropColor(0, 0, 0, .4) Subtlety.displayFrame:EnableMouse(true) else Subtletydb.locked = true Subtlety.displayFrame:SetScript("OnMouseDown", nil) Subtlety.displayFrame:SetScript("OnMouseUp", nil) Subtlety.displayFrame:SetScript("OnDragStop", nil) Subtlety.displayFrame:SetBackdropColor(0, 0, 0, 0) Subtlety.displayFrame:EnableMouse(false) end end function Subtlety:GetScale() return Subtletydb.scale end function Subtlety:SetScale(num) Subtletydb.scale = num Subtlety.displayFrame:SetScale(Subtletydb.scale) Subtlety.cooldownFrame:SetScale(Subtletydb.scale) end function Subtlety.Options(msg, editBox) if(msg == 'show') then Subtlety.displayFrame:Show() elseif(msg == 'hide') then Subtlety.displayFrame:Hide() elseif(msg == '') then InterfaceOptionsFrame_OpenToCategory(getglobal("SubtletyOptions")) else end end function Subtlety:GetRupturePoints() return Subtletydb.RupturePoints end function Subtlety:SetRupturePoints(num) Subtletydb.RupturePoints = num end function Subtlety:GetRupturePriority() return Subtletydb.RupturePriority end function Subtlety:SetRupturePriority(num) Subtletydb.RupturePriority = num end function Subtlety:GetSliceAndDicePoints() return Subtletydb.SliceAndDicePoints end function Subtlety:SetSliceAndDicePoints(num) Subtletydb.SliceAndDicePoints = num end function Subtlety:GetSliceAndDicePriority() return Subtletydb.SliceAndDicePriority end function Subtlety:SetSliceAndDicePriority(num) Subtletydb.SliceAndDicePriority = num end function Subtlety:GetVanish() return Subtletydb.SuggestVanish end function Subtlety:GetShadowDance() return Subtletydb.SuggestShadowDance end function Subtlety:GetBackstab() return Subtletydb.SuggestBackstab end function Subtlety:GetTotT() return Subtletydb.SuggestTotT end function Subtlety:ToggleVanish() if(Subtletydb.SuggestVanish == true) then Subtletydb.SuggestVanish = false else Subtletydb.SuggestVanish = true end end function Subtlety:ToggleShadowDance() if(Subtletydb.SuggestShadowDance == true) then Subtletydb.SuggestShadowDance = false else Subtletydb.SuggestShadowDance = true end end function Subtlety:ToggleBackstab() if(Subtletydb.SuggestBackstab == true) then Subtletydb.SuggestBackstab = false Subtlety.L["Generator"] = Subtlety.L["Backstab"] else Subtletydb.SuggestBackstab = true Subtlety.L["Generator"] = Subtlety.L["Hemorrhage"] end end function Subtlety:ToggleTotT() if(Subtletydb.SuggestTotT == true) then Subtletydb.SuggestTotT = false else Subtletydb.SuggestTotT = true end end |
|
07-31-14, 07:16 PM | #2 |
1) Make sure you have BugSack enabled to check for error messages. The game's built-in error display is useless for developers, since it cannot show you errors that happen during loading, and that's exactly when most errors happen during development.
2) Add a print statement in each function so you can see what's happening in real-time, eg: Code:
Subtlety.eventFrame:SetScript("OnEvent", function(this, event, ...) print("Subtlety", event, ...) Subtlety.events[event](...) end) 3) Some other issues not related to the loading problem, in no particular order: - UnitName returns a value for the player unit immediately; you don't need to wait for PLAYER_LOGIN to get it. - Rather than making your main addon object a plain table, and creating a separate object to handle events, just make your addon a frame. You can use the same frame to display stuff, too; you don't need separate display and event-handling frames. - You're wasting a lot of space on hard-coded translations for spell names, when you just overwrite them all with values from GetSpellInfo anyway. There's no reason to hardcode spell names; get rid of all that and just use the GetSpellInfo values. Also, the "Generator" entry in your localization table is not actually for localization -- it's a data container. Put it with the other variables (currentTarget, playerName, etc.), not with the localization strings. - Avoid putting things in the global namespace that don't need to be there. Your "FM_GetSpellNameById" function is currently global, but you don't even use it anywhere, and it's really nothing but a wrapper around GetSpellInfo; just get rid of it. - Use object notation properly. Instead of "object.function(arg)" do "object:function(arg)" so you can access the object with "self" inside the function. - Don't re-recreate the same tables and functions over and over again inside another function (eg. your DecideSpells function). Create those objects one time, and then refer to them inside the function. - Wrapper functions like this are totally pointless and just waste CPU cycles on function calls, which are pretty much the slowest thing you can do in Lua: Code:
function Subtlety:GetScale() return Subtletydb.scale end
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
07-31-14, 07:46 PM | #3 |
Thank you for seeing me so quickly ...
Unfortunately I have no programming knowledge, I only edit simple things like resize windows, this code I pulled out of an addon and noticed this error, all these instructions you gave me unfortunately I do not know how it would be possible to please you the necessary changes for me? If possible, I would be very grateful, because the addon is very useful me. |
|
07-31-14, 09:06 PM | #4 |
Is GetSpecialization() really ready by ADDON_LOADED?
|
|
08-01-14, 02:08 AM | #5 |
Possible someone would make changes or corrections to me?
Unfortunately I have no knowledge of code or programming to do this ... |
|
08-01-14, 03:34 AM | #6 |
I have no use for a "rotation helper" nor any interest in writing one, sorry. If you're not able or willing to learn how to write/modify addon code yourself, why don't you just use another addon? There are plenty of rotation helper addons, if you really need an addon to tell you how to play...
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
WoWInterface » Developer Discussions » General Authoring Discussion » [HELP] Addon only works after /reload |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|