Thread: the _G changes.
View Single Post
09-17-10, 11:43 AM   #10
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Only the last error has anything to do with the changes to this, and only changing this to self won't fix it, you also need to update the function declarations to include that self is passed:
lua Code:
  1. _G.SlashCmdList["GTIPNOTES_SHORTHAND"] = function(input)
  2.     if not UnitExists('target') then
  3.         print(TARGET_ERROR)
  4.         return
  5.     end
  6.     input = input:trim()
  7.     if type(input) ~= 'string' or input == "" then
  8.         if not StaticPopupDialogs["GTipNotes"] then
  9.             StaticPopupDialogs["GTipNotes"] = {
  10.                 text = nil,
  11.                 button1 = SET,
  12.                 button2 = CANCEL,
  13.                 whileDead = 1,
  14.                 hideOnEscape = 1,
  15.                 timeout = 0,
  16.                 OnShow = function(self)
  17.                     -- We have to do this onshow to reset the previous text
  18.                     local name = UnitExists("target") and UnitName("target") or ""
  19.                     _G[self:GetName() .. "EditBox"]:SetText(_G.GTipNotesDB[name] or "")
  20.                 end,
  21.                 OnHide = function(self)
  22.                     _G[self:GetName() .. "EditBox"]:SetText("")
  23.                 end,
  24.                 EditBoxOnEnterPressed = function(self)
  25.                     addNoteFromPopup(_G[self:GetParent():GetName() .. "EditBox"]:GetText())
  26.                     self:GetParent():Hide()
  27.                 end,
  28.                 EditBoxOnEscapePressed = function(self)
  29.                     self:GetParent():Hide()
  30.                 end,
  31.                 OnAccept = function(self)
  32.                     addNoteFromPopup(_G[self:GetParent():GetName() .. "EditBox"]:GetText())
  33.                 end,
  34.                 hasEditBox = 1,
  35.             }
  36.         end
  37.         StaticPopupDialogs["GTipNotes"].text = POPUP_TEXT:format(UnitName('target'))
  38.         StaticPopup_Show("GTipNotes")
  39.     else
  40.         local name = UnitName('target')
  41.         _G.GTipNotesDB[name] = input
  42.         print(NOTE_SET:format(name, input))
  43.     end
  44. end

The issue with FriendsFrame code is that Blizzard changed it and no longer uses/sets FriendsFrameFriendsScrollFrame.usedButtons:
lua Code:
  1. hooksecurefunc('FriendsList_Update', function()
  2.     local buttons, button = FriendsFrameFriendsScrollFrame.buttons
  3.     local colors, CLASS = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS, addon.CLASS
  4.     for index = 1, #buttons do
  5.         button = buttons[index]
  6.         if button:IsShown() then
  7.             if button.buttonType == FRIENDS_BUTTON_TYPE_WOW then
  8.                 local _, _, class, _, connected = GetFriendInfo(button.id)
  9.                 if connected then
  10.                     local color = colors[CLASS[class]]
  11.                     button.name:SetTextColor(color.r, color.g, color.b)
  12.                 end
  13.             end
  14.         else
  15.             break
  16.         end
  17.     end
  18. end)

Part of the problem with the first error is that the ammo slot was removed which is what slots[0] is, so remove the start variable and always begin with an id of 1:
lua Code:
  1. local function CreateBorders(frame, prefix)
  2.     local border = { }
  3.     for id = 1, #slots do
  4.         local frame = _G[prefix .. slots[id]]
  5.         local region = GetNormalTexture(frame:GetRegions())
  6.         local texture = frame:CreateTexture(nil, 'OVERLAY')
  7.         texture:SetTexture([[Interface\Buttons\UI-ActionButton-Border]])
  8.         texture:SetBlendMode('ADD')
  9.         texture:SetAlpha(0.8)
  10.         texture:SetPoint('TOPLEFT', region, -1, 3)
  11.         texture:SetPoint('BOTTOMRIGHT', region, 1, 0)
  12.         border[id] = texture
  13.     end
  14.     borders[frame] = border
  15. end

There may still be errors after making those changes, I don't have access to check, but at least you will be one step closer to fixing it.