1. I think I am almost done this addon, but there are a couple of things that elude me. I stripped out all the cruft, stuff that didn't work, or wasn't necessary, but there is some commented code I will get back to once the main purpose is working.

    paste http://pastey.net/147891

    Anyway, my math error says the first value of allManaValues is nil, and I can't spot why. It should be an easy fix, but I am blind apparently. Error code:

     1x AverageCombatMana-@project-version@\AverageCombatMana.lua:296: attempt to perform arithmetic on local 'allManaSum' (a nil value)
     CallbackHandler-1.0-6 (Ace3):147: in function <...Ons\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:147>
     <string>:"safecall Dispatcher[1]":4: in function <[string "safecall Dispatcher[1]"]:4>
     <in C code>: ?
     <string>:"safecall Dispatcher[1]":13: in function `?'
     CallbackHandler-1.0-6 (Ace3):92: in function `Fire'
     AceEvent-3.0-3 (Ace3):120: in function <Ace3\AceEvent-3.0\AceEvent-3.0.lua:119>
    

    The second problem is with lines 123 - 138. The segments are not colouring. The bar remains basic black. Again, I'm baffled. This leads, of course, to the last problem (that I know of) which is ManaDisplay.indicator. I am using the PvP capture frame to show and move the indicator, but the graphic is not showing up, and I am fairly certain the indicator itself isn't even moving with the value on line 379.

    Any feedback welcome, and many thanks!

  2. I think I am almost done this addon, but there are a couple of things that elude me. I stripped out all the cruft, stuff that didn't work, or wasn't necessary, but there is some commented code I will get back to once the main purpose is working.

    paste http://pastey.net/147891

    Anyway, my math error says the first value of allManaValues is nil, and I can't spot why. It should be an easy fix, but I am blind apparently. Error code:

     1x AverageCombatMana-@project-version@\AverageCombatMana.lua:296: attempt to perform arithmetic on local 'allManaSum' (a nil value)
     CallbackHandler-1.0-6 (Ace3):147: in function <...Ons\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:147>
     <string>:"safecall Dispatcher[1]":4: in function <[string "safecall Dispatcher[1]"]:4>
     <in C code>: ?
     <string>:"safecall Dispatcher[1]":13: in function `?'
     CallbackHandler-1.0-6 (Ace3):92: in function `Fire'
     AceEvent-3.0-3 (Ace3):120: in function <Ace3\AceEvent-3.0\AceEvent-3.0.lua:119>
    

    It's pretty simple. On line 291 you 'declare' allManaSum but never give it a value. Then on line 296 you use it in arithmetic and you can't add a number to nil. You need to give it a value in order to add to it, probably 0.

    The second problem is with lines 123 - 138. The segments are not colouring. The bar remains basic black. Again, I'm baffled. This leads, of course, to the last problem (that I know of) which is ManaDisplay.indicator. I am using the PvP capture frame to show and move the indicator, but the graphic is not showing up, and I am fairly certain the indicator itself isn't even moving with the value on line 379.

    SetVertexColor on a font strings isn't a great way to do things and probably doesn't even work. Any particular reason you're not just using color escape sequences?

  3. It's pretty simple. On line 291 you 'declare' allManaSum but never give it a value. Then on line 296 you use it in arithmetic and you can't add a number to nil. You need to give it a value in order to add to it, probably 0.

    Yes, that fixed it. Silly mistake, but there you go.

    The second problem is with lines 123 - 138. The segments are not colouring. The bar remains basic black. Again, I'm baffled. This leads, of course, to the last problem (that I know of) which is ManaDisplay.indicator. I am using the PvP capture frame to show and move the indicator, but the graphic is not showing up, and I am fairly certain the indicator itself isn't even moving with the value on line 379.

    SetVertexColor on a font strings isn't a great way to do things and probably doesn't even work. Any particular reason you're not just using color escape sequences?

    I wasn't trying to use SetVertexColor on font strings, I was trying to set it on segments of a frame. The segments are created just above with the following lines. Actually, my original intent was to use SetGradientAlpha but I couldn't get it to apply to the texture, so I am colouring the segments manually.

     ManaDisplay.segments = ManaDisplay.segments or {}
    
        for i = -10, 10 do
            local t = ManaDisplay.segments[i] or ManaDisplay:CreateTexture(nil, "ARTWORK")
            t:SetPoint("LEFT", ManaDisplay.segments[i - 1], "RIGHT", 0, 0)
            t:SetWidth(1)
            t:SetHeight(ManaDisplay:GetHeight() - 10)
            t:SetTexture(TEXTURE)
            t:SetAlpha(0.8)
            ManaDisplay.segments[i] = t
        end
    
        -- mana loss
        for i = -10, -2 do
            local k = i/10
            ManaDisplay.segments[i]:SetVertexColor(k, 0, 0)
        end
    
        -- neither gain nor loss
        ManaDisplay.segments[-1]:SetVertexColor(0, 0, 0.5)
        ManaDisplay.segments[0]:SetVertexColor(0, 0, 1)
        ManaDisplay.segments[1]:SetVertexColor(0, 0, 0.5)
    
        -- mana gain
        for i = 2, 10 do
            local k = i/10
            ManaDisplay.segments[i]:SetVertexColor(0, k, 0)
        end
    

    Just wondering what was wrong with that idea? I am using SetTextColor to color the font strings.

    I ran into another problem, this time with SendChatMessage. I have read, reread, and reread the API and fail to see why it is asking for an additional ')' to this line.

    SendChatMessage((L["Average Mana gain or loss for the entire fight was"].." %d", chatType, nil, nil), combatAverage)

    combatAverage is an integer. The core file section reads

     if self.db.profile.chatOutput ~= "0-none" then
        local chatType = self.db.profile.chatOutput:upper()
        if chatType == "2-smartGroup" then
            if UnitInRaid("player") then
                chatType = "RAID"
            elseif GetNumPartyMembers() > 0 then
                chatType = "PARTY"
            end
        elseif self.db.profile.chatOutput == "1-self" then
            self:Print(L["Average Mana gain or loss for the entire fight was"], combatAverage)
        else
            SendChatMessage((L["Average Mana gain or loss for the entire fight was"].." %d", chatType, nil, nil), combatAverage)
        end
     end
    

    And the options file reads

     chatOutput = {
        order = 50,
        type = "select",
        name = CHAT_OPTIONS_LABEL,
        desc = L["Chat channel you want your overall Mana regen to print. Smart Group will select Party or Raid depending on group type"],
        values = {
            ["0-none"] = NONE,
            ["1-self"] = YOU,                           
            ["2-smartGroup"] = L["Smart Group"],
            guild = CHAT_MSG_GUILD,
            party = CHAT_MSG_PARTY,
            raid = CHAT_MSG_RAID,
            say = CHAT_MSG_SAY,
            yell = CHAT_MSG_YELL
        },
        get = function() return self.db.profile.chatOutput end,
        set = function(info, value) self.db.profile.chatOutput = value end
     }
    
  4. It's pretty simple. On line 291 you 'declare' allManaSum but never give it a value. Then on line 296 you use it in arithmetic and you can't add a number to nil. You need to give it a value in order to add to it, probably 0.

    Yes, that fixed it. Silly mistake, but there you go.

    The second problem is with lines 123 - 138. The segments are not colouring. The bar remains basic black. Again, I'm baffled. This leads, of course, to the last problem (that I know of) which is ManaDisplay.indicator. I am using the PvP capture frame to show and move the indicator, but the graphic is not showing up, and I am fairly certain the indicator itself isn't even moving with the value on line 379.

    SetVertexColor on a font strings isn't a great way to do things and probably doesn't even work. Any particular reason you're not just using color escape sequences?

    I wasn't trying to use SetVertexColor on font strings, I was trying to set it on segments of a frame. The segments are created just above with the following lines. Actually, my original intent was to use SetGradientAlpha but I couldn't get it to apply to the texture, so I am colouring the segments manually.

     ManaDisplay.segments = ManaDisplay.segments or {}
      
      for i = -10, 10 do
          local t = ManaDisplay.segments[i] or ManaDisplay:CreateTexture(nil, "ARTWORK")
          t:SetPoint("LEFT", ManaDisplay.segments[i - 1], "RIGHT", 0, 0)
          t:SetWidth(1)
          t:SetHeight(ManaDisplay:GetHeight() - 10)
          t:SetTexture(TEXTURE)
          t:SetAlpha(0.8)
          ManaDisplay.segments[i] = t
      end
      
      -- mana loss
      for i = -10, -2 do
          local k = i/10
          ManaDisplay.segments[i]:SetVertexColor(k, 0, 0)
      end
      
      -- neither gain nor loss
      ManaDisplay.segments[-1]:SetVertexColor(0, 0, 0.5)
      ManaDisplay.segments[0]:SetVertexColor(0, 0, 1)
      ManaDisplay.segments[1]:SetVertexColor(0, 0, 0.5)
      
      -- mana gain
      for i = 2, 10 do
          local k = i/10
          ManaDisplay.segments[i]:SetVertexColor(0, k, 0)
      end
    

    Just wondering what was wrong with that idea? I am using SetTextColor to color the font strings.

    Nothing I guess, if that's what you're doing.

    I ran into another problem, this time with SendChatMessage. I have read, reread, and reread the API and fail to see why it is asking for an additional ')' to this line.

    Please do not ever paraphrase error messages. Give me the exact error message that you receive in-game along with the line number and a pastey of the code so I can figure out what line is the culprit.

    SendChatMessage((L["Average Mana gain or loss for the entire fight was"].." %d", chatType, nil, nil), combatAverage)

    The error message you claim to have is not correct. What you are getting is:

     ')' expected near ','
    

    That's because your code doesn't have proper syntax:

     SendChatMessage((L["Average Mana gain or loss for the entire fight was"].." %d", chatType, nil, nil), combatAverage)
    

    The SendChatMessage function takes arguments, in this case you're trying to pass five arguments, but you've got a bizarre set of parenthesis where they shouldn't be.

    Try this:

     SendChatMessage(L["Average Mana gain or loss for the entire fight was"].." %d", chatType, nil, nil, combatAverage)
    

    Simple, no syntax errors.

    combatAverage is an integer. The core file section reads

     if self.db.profile.chatOutput ~= "0-none" then
      local chatType = self.db.profile.chatOutput:upper()
      if chatType == "2-smartGroup" then
          if UnitInRaid("player") then
              chatType = "RAID"
          elseif GetNumPartyMembers() > 0 then
              chatType = "PARTY"
          end
      elseif self.db.profile.chatOutput == "1-self" then
          self:Print(L["Average Mana gain or loss for the entire fight was"], combatAverage)
      else
          SendChatMessage((L["Average Mana gain or loss for the entire fight was"].." %d", chatType, nil, nil), combatAverage)
      end
     end
    

    And the options file reads

     chatOutput = {
      order = 50,
      type = "select",
      name = CHAT_OPTIONS_LABEL,
      desc = L["Chat channel you want your overall Mana regen to print. Smart Group will select Party or Raid depending on group type"],
      values = {
          ["0-none"] = NONE,
          ["1-self"] = YOU,                           
          ["2-smartGroup"] = L["Smart Group"],
          guild = CHAT_MSG_GUILD,
          party = CHAT_MSG_PARTY,
          raid = CHAT_MSG_RAID,
          say = CHAT_MSG_SAY,
          yell = CHAT_MSG_YELL
      },
      get = function() return self.db.profile.chatOutput end,
      set = function(info, value) self.db.profile.chatOutput = value end
     }
    

    You don't ask a question here.. I assume its related to the SendChatMessage call, but not relevant.

    Always trust the error messages that Lua gives you. They are always correct.