• 0

    posted a message on Need help with some errors
    Your chat output is set to "2-none"? lol
    Posted in: Lua Code Discussion
  • 0

    posted a message on Need help with some errors
    You are setting firstManaValue to nil when you exit combat. Depending on settings, I notice you may not be hiding the ManaDisplay frame at the same time, so the OnUpdate script of the frame continues to run, and give you a nil error. You can fix this by setting the OnUpdate script to nil if you don't wish to hide the frame.

    You are also creating a new function to assign to the OnUpdate script every time you enter combat. Consider creating the function once at the main file level instead, and then use a reference to it.

    Your CreateSegments() function is still creating thousands of textures. With my 108k mana, if I were to run your addon, I would create 21601 textures, most of which wouldn't even show on the screen. Since you're parenting each texture to the next one before it, only 1900 of those textures would ever be visible on the screen if your resolution is that wide and your frame starts all the way on the left.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Need help with some errors
    According to your code, if your user has 108k max mana (well my mage does when buffed), then you are creating 43201 textures (lines 378-386) from i = -21600 to 21600. Are you sure that's what you really want to do? I'm surprised WoW didn't crash with an out of memory error or something.

    What you really need to do is create exactly 20 textures/segments, and use math to figure out what range of mana corresponds to each texture. (Hint: Every 10800 mana is one segment in my example.)

    You will need to rewrite quite a bit of your segment code.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Need help with some errors
    enUS doesn't actually need to be the first locale registered. Locales can be registered in any order (but only one of them should be default), AceLocale-3.0 handles it properly.

    The error means exactly what it says, the 4th argument (isSilent, default false) if specified as true, must be done the first locale being registered for the application.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Grid — compact party/raid unit frames
    The location depends on where his World of Warcraft is installed as well as whether UAC is turned on, but you got it right, its either in the Virtual Store, or in the WoW folder, and you mentioned both.

    Did he copy the file while WoW is running? Because that won't work, when he exits or reloads, WoW will overwrite the "new one to be used" with his current unwanted settings.
    Posted in: Grid & Grid2
  • 0

    posted a message on Circular tables in lua ?
    A linked list will not save you memory in Lua. It will instead use MORE memory because each table has an overhead of 40 bytes, and the table pointer (the "next" key-value pair) to the next table is another 16 bytes. Please use the standard Lua tables as hash tables or array tables.

    If each "item" in the linked list is meant to be another table of items, you can either use multiple tables of each subitem, or you can have an array of table of items. Table keys can be any object that isn't nil.
    Posted in: Need Help?
  • 0

    posted a message on table optimization and logic
    You didn't paste updated code. You copied the links from previous post lol. Since we're talking about optimizations, you would do better changing this:

    self.message:SetText(L["Gaining Mana!"].."\n".."%d", averageMana)

    to

    self.message:SetFormattedText(L["Gaining Mana!\n%d"], averageMana)

    And other multiple other similar cases. Translators know not to touch the \n and %d parts of the string when translating to another language.

    I also bet you never actually noticed that you were setting the text "Gaining Mana!\n%d" literally, without calling format() like you should have:

    self.message:SetText(format(L["Gaining Mana!"].."\n".."%d", averageMana))

    It kind of begs the question, did you actually test your own addon at all? Do you just write lots of code and hope it works later? I'll suggest not doing this, and only writing bits of code, making sure it works first, then add more code, and then checking that works perfectly, etc.
    Posted in: Lua Code Discussion
  • 0

    posted a message on table optimization and logic
    Nope, you have not fixed the memory leak issue. Hint:

    local t = self.ManaDisplay or self.ManaDisplay:CreateTexture(nil, "ARTWORK")
    ---------->
    local t = self.ManaDisplay.segments[i] or self.ManaDisplay:CreateTexture(nil, "ARTWORK")

    You always want to retrieve the existing texture, and only if it returns nil, then call the creation of the new texture.

    Line 387 has another error:

    self.indicator:SetPoint("CENTER", self.ManaDisplay.segments[averageMana], "RIGHT")

    The first use of "self" is correct, but the second isn't. Did you mean self.segments[averageMana]? Inside the OnUpdate script, self refers to the frame that fired the event, not the ACM addon table.

    Line 9 and 12 of the options doesn't seem to be used.
    local AceConfigDialog = LibStub("AceConfigDialog-3.0")
    local AceConfig = LibStub("AceConfig-3.0")

    Note that your ManaDisplay frame with the OnUpdate will only be running if the frame is visible. If you hide this frame, the OnUpdate stops running and will not be recording any data. If you want background recording of data, it might be necessary to use another separate frame.
    Posted in: Lua Code Discussion
  • 0

    posted a message on WSG rez timer addon
    Ooops, somehow I read that as WG lol.

    I'm not sure about the desync issue in WSG since I have not tested this before, but only tested the WG and AB ones. It appears that GY changing and ressing doesn't occur exactly X seconds from the point of capture, the game only checks every Y seconds to see if it should change hands, and thus there's always a Y seconds variable of uncertainty that can slip by.
    Posted in: Addon Ideas
  • 0

    posted a message on WSG rez timer addon
    Because graveyards in WG do change hands, when the factories get destroyed or captured. Also due to server lag whenever there is concentrated battle in one area, the GY rezzing timers slowly desync.
    Posted in: Addon Ideas
  • 0

    posted a message on table optimization and logic
    You're doing it fine. But Vexxilus is correct, you will do far better getting rid of the useless manaValues[] table, and just loop over the last 5 values of the allManaValues[] table, because I don't see any other location in the code that uses the manaValues[] table other than the OnUpdate function.

    Plus, your OnUpdate function isn't even used. It's defined and declared on line 391, so only code beyond line 391 will even recognize the file scope "OnUpdate" variable. As such, the function will just get garbage collected immediately when the addon finishes loading since there is nothing after the function that references it.

    Is your code you are providing incomplete?

    Lines 334 and 336 appear to be missing "" around the monochrome and outline variables, you surely didn't want to compare against variables that don't exist.

    You have not fixed the memory leak between lines 303-310.
    Posted in: Lua Code Discussion
  • 0

    posted a message on savedVariables ?
    The variable(s) you declared in ## SavedVariables in your TOC file must be in global scope. You declared buffs in local file scope in your addon so nothing got saved as the global buffs variable doesn't exist.

    You should also rename your SavedVariable from buffs to something more unique, because any addon could accidentally overwrite your "buffs" global variable with such a generic name.
    Posted in: AddOn HELP!
  • 0

    posted a message on table optimization and logic
    I also just noticed a major memory leak in the ACM:CreateSegments() function. It appears that you are calling this function in every UNIT_POWER event that changes the user's maximum mana. This will occur a lot when buffs are being cast/removed from the player such as MotW, Arcane Intellect, etc.

    You are creating new frames, new fontstrings and new textures every time CreateSegments() is called without checking to see if there are already existing ones that can be reused. You will need to update your code to check for existing frames...

    Something like this:

    self.ManaDisplay.segments = {} -- wrong
    self.ManaDisplay.segments = self.ManaDisplay.segments or {} -- right
    
    self.ManaDisplay.message = self.ManaDisplay:CreateFontString(nil, "OVERLAY")  -- wrong
    self.ManaDisplay.message = self.ManaDisplay.message or self.ManaDisplay:CreateFontString(nil, "OVERLAY") -- right


    and so on.
    Posted in: Lua Code Discussion
  • 0

    posted a message on table optimization and logic
    I don't have anything to add yet (until I see updated code pasteyed), except the following:

    A) Don't use ipairs() in loops. It's slower than a standard "for k = 1, #t do local v = t[k]" loop

    B)
    self.ManaDisplay = CreateFrame("Frame", "self.ManaDisplay", UIParent)

    The string used to name the frame globally is weird, since it has a . in it, you would need to use _G["self.ManaDisplay"] to access the frame globally. since you already stored the frame in self.ManaDisplay, you shouldn't have to name your frame at all.
    self.ManaDisplay = CreateFrame("Frame", nil, UIParent)


    C) Strange usage of "not" keyword in multiple places:
    if (not unit == "player") or (not powerType == "MANA") then return end

    Change to
    if (unit ~= "player") or (powerType ~= "MANA") then return end
    Posted in: Lua Code Discussion
  • 0

    posted a message on assign value to a matrix... how to?
    You seem to be creating #buff number of notify[] tables, but your loop later loops over 40 buffs. You also seem to have one loop in the other, so you would be checking for 40 buffs #buff number of times.
    Posted in: AddOn HELP!
  • To post a comment, please or register a new account.