WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   oUF Style already registered.. (https://www.wowinterface.com/forums/showthread.php?t=55971)

Tim 01-13-18 03:20 PM

oUF Style already registered..
 
I can't figure out for the life of me how to fix that error.

oUF: Error: Style [LiteUI_Boss] already registered.

Code:

local addon, ns = ...
local E, C, M, UF, oUF = ns.E, ns.C, ns.M, ns.UF, ns.oUF


if not C.SETTINGS.units.boss.enabled then return end


local CreateBoss = function(self)

  local unit = "boss"

  self:SetSize(112, 47)
  self:SetFrameLevel(3)

  UF.CreateHealth(self, unit, 107, 32, "CENTER", "CENTER", -2, 8)
  UF.CreatePower(self, unit, 87, 5, "CENTER", "CENTER", 2, -20)

  UF.CreateNameText(self, "LEFT", "LEFT", 4, 15, 11, "OUTLINE", "LEFT")
  UF.CreateHealthTextPercent(self, "RIGHT", "RIGHT", 0, -6, 11, "OUTLINE", "RIGHT")

  UF.CreateArtwork(self, unit)

  UF.CreateRaidIcon(self, "BOTTOM", "TOP", 0, 14)

  UF.SetTooltip(self, unit)

end



oUF:RegisterStyle(addon.."_Boss", CreateBoss)
oUF:SetActiveStyle(addon.."_Boss")

local boss = {}

for i = 1, MAX_BOSS_FRAMES do

  boss[i] = oUF:Spawn("boss"..i, addon.."_Boss"..i)

  if (i == 1) then

      boss[i]:SetPoint(unpack(C.SETTINGS.units.boss.pos))

  else

      boss[i]:SetPoint("TOP", boss[i-1], "BOTTOM", 0, -10)

  end

end


lightspark 01-13-18 04:29 PM

Are you sure that that's the only place w/:

Lua Code:
  1. oUF:RegisterStyle(addon.."_Boss", CreateBoss)

Might be a copypasta elsewhere :p

Tim 01-13-18 04:34 PM

Yep, that's the only instance of that line.

lightspark 01-13-18 05:12 PM

Hm, that's weird because that's the only reason why this could happen o_O

It means that a style w/ the same name was registered elsewhere.

Tim 01-13-18 05:16 PM

Yeah I know. I even looked at ouf.lua to see if I looked over something and was actually doing something wrong which I wasn't so I was stumped and posted here. The style for the boss frames do work 100% but, that error message annoys me and I wanted to see if there was some other solution. I may just go and edit the ouf file and comment out the error line, lol.

lightspark 01-13-18 05:21 PM

TBF, if I were you I'd add a bunch of prints w/ debugstacks to see what and where is registering styles :p

-- edit #1

I mean add the following code here:
Lua Code:
  1. print("style:", name)
  2. print(debugstack(2, 2, 0))

This way you'll be able to see from where RegisterStyle was called.

Tim 01-13-18 05:44 PM

I had added prints in the for loop earlier and did notice it was basically looping through it twice. Perhaps that could be the cause of it?

lightspark 01-13-18 05:53 PM

Hm, given that your for loop isn't inside of any function, it means that your file is read more than once.

Are you sure that it isn't referred in an xml file or somewhere else more than once?

Code:

<Ui xmlns="http://www.blizzard.com/wow/ui/">
        <Script file="file.lua"/>
        <Script file="file.lua"/>
</Ui>

The content of file.lua will be read twice in this case, and everything executable/callable will be executed/called twice as well.

Tim 01-13-18 05:57 PM

LOL, that was it.. geeze I feel retarded, haha. ty <3

lightspark 01-13-18 05:58 PM

LOL :D YW :banana:


All times are GMT -6. The time now is 12:47 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI