Thread Tools Display Modes
Unread 09-16-10, 11:59 PM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 975
the _G changes.

can someone explain this better. "The getglobal and setglobal functions are considerd deprecated, and have been removed from the C API's. In the interests of compatibility there remain lua implementations of both, but new code should be updated to use x = _G[globalName] and _G[globalName] = x instead."

what code should be updated? i think this is where the problems with my ui are but not exactly sure why does it mean things like this _G[prefix .. slots[id]] need to be changed? or _G[this:GetName().. ?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
Grimsin is offline  
Unread 09-17-10, 12:14 AM   #2
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 714
No, only setglobal(prefix .. slots[id], "SOMEVALUE") needs to be updated to _G[prefix .. slots[id]] = "SOMEVALUE".

If you didn't use setglobal or getglobal, then you shouldn't be worried.
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
nightcracker is offline  
Unread 09-17-10, 07:52 AM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 975
hmmm, well im still confused then about one change or another. I get what appears to be the same value = nil error on a few different chunks of code. some of the chunks are as follows.

lua Code:
  1. local function CreateBorders(frame, prefix)
  2.     local border, start = { }, frame == CharacterFrame and 0 or 1
  3.     for id = start, #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
  16.  
  17. local function OnHide(self)
  18.     addon.UnregisterEvent(self, 'UNIT_INVENTORY_CHANGED')
  19. end
  20.  
  21. local function OnShow(self)
  22.     addon.RegisterEvent(self, 'UNIT_INVENTORY_CHANGED', UpdateItemQualityBorders)
  23.     UpdateItemQualityBorders(self, nil, self.unit)
  24. end
  25.  
  26. local function HookFrame(frame, prefix)
  27.     CreateBorders(frame, prefix)
  28.     frame:HookScript('OnHide', OnHide)
  29.     frame:HookScript('OnShow', OnShow)
  30. end
  31.  
  32. HookFrame(CharacterFrame, 'Character')
  33. CharacterFrame.unit = 'player'
  34.  
  35. if InspectFrame then
  36.     HookFrame(InspectFrame, 'Inspect')
  37. else
  38.     addon.RegisterEvent("Features-MonitorInspectUI", 'ADDON_LOADED', function(self, event, name)
  39.         if name ~= 'Blizzard_InspectUI' then return end
  40.         addon.UnregisterEvent(self, event)
  41.  
  42.         HookFrame(InspectFrame, 'Inspect')
  43.         if InspectFrame:IsShown() then
  44.             UpdateItemQualityBorders(InspectFrame, nil, InspectFrame.unit)
  45.         end
  46.     end)
  47. end

or this chunk

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, FriendsFrameFriendsScrollFrame.usedButtons do
  5.         button = buttons[index]
  6.         if button.buttonType == FRIENDS_BUTTON_TYPE_WOW then
  7.             local _, _, class, _, connected = GetFriendInfo(button.id)
  8.             if connected then
  9.                 local color = colors[CLASS[class]]
  10.                 button.name:SetTextColor(color.r, color.g, color.b)
  11.             end
  12.         end
  13.     end
  14. end)

and last but not least this chunk also
lua Code:
  1. _G.SlashCmdList["GTIPNOTES_SHORTHAND"] = function(input)
  2.     if not UnitExists("target") then
  3.         DEFAULT_CHAT_FRAME:AddMessage(TARGET_ERROR)
  4.         return
  5.     end
  6.     if type(input) ~= "string" or input:trim():len() == 0 then
  7.         if not StaticPopupDialogs["GTipNotes"] then
  8.             StaticPopupDialogs["GTipNotes"] = {
  9.                 text = nil,
  10.                 button1 = SET,
  11.                 button2 = CANCEL,
  12.                 whileDead = 1,
  13.                 hideOnEscape = 1,
  14.                 timeout = 0,
  15.                 OnShow = function()
  16.                     -- We have to do this onshow to reset the previous text
  17.                     local t = UnitExists("target") and UnitName("target") or ""
  18.                     _G[this:GetName().."EditBox"]:SetText(_G.GTipNotesDB[t] or "")
  19.                 end,
  20.                 OnHide = function()
  21.                     _G[this:GetName().."EditBox"]:SetText("")
  22.                 end,
  23.                 EditBoxOnEnterPressed = function()
  24.                     addNoteFromPopup(_G[this:GetParent():GetName().."EditBox"]:GetText())
  25.                     this:GetParent():Hide()
  26.                 end,
  27.                 EditBoxOnEscapePressed = function()
  28.                     this:GetParent():Hide()
  29.                 end,
  30.                 OnAccept = function()
  31.                     addNoteFromPopup(_G[this:GetParent():GetName().."EditBox"]:GetText())
  32.                 end,
  33.                 hasEditBox = 1,
  34.             }
  35.         end
  36.         StaticPopupDialogs["GTipNotes"].text = POPUP_TEXT:format(UnitName("target"))
  37.         StaticPopup_Show("GTipNotes")
  38.     else
  39.         local t = UnitName("target")
  40.         _G.GTipNotesDB[t] = input
  41.         DEFAULT_CHAT_FRAME:AddMessage(NOTE_SET:format(t, input))
  42.     end
  43. end

all works on live servers so it has to be the cata changes that caused this im just not sure which one or why.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
Grimsin is offline  
Unread 09-17-10, 08:55 AM   #4
IQgryn
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 46
Originally Posted by Grimsin View Post
hmmm, well im still confused then about one change or another. I get what appears to be the same value = nil error on a few different chunks of code. some of the chunks are as follows.

<snip>
Which lines are causing the nil errors?
IQgryn is offline  
Unread 09-17-10, 09:31 AM   #5
Beoko
A Cyclonian
 
Beoko's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 41
* The global variables this, event and arg1, arg2... have been removed. Event handlers and other callbacks must use the appropriate locals.
These changes are present as well.
Beoko is offline  
Unread 09-17-10, 09:45 AM   #6
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 975
my use of "this" in the tooltips code i changed to self and got a way different error, i dont think the use of this in that instance is the same as what was changed? if so i should of been able to simply change this to self or at lest that was my understanding.

the exact line that it starts in the 3rd chunk of code is this one, it says "this" is a nil value
_G[this:GetName().."EditBox"]:SetText(_G.GTipNotesDB[t] or "")

in the first chunk of code it is this one, this one says "frame" is a nil value
local region = GetNormalTexture(frame:GetRegions())

in the 2nd chunk of code im not sure which line it was i have to go back and check.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
Grimsin is offline  
Unread 09-17-10, 10:13 AM   #7
IQgryn
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 46
Originally Posted by Grimsin View Post
my use of "this" in the tooltips code i changed to self and got a way different error, i dont think the use of this in that instance is the same as what was changed? if so i should of been able to simply change this to self or at lest that was my understanding.

the exact line that it starts in the 3rd chunk of code is this one, it says "this" is a nil value
_G[this:GetName().."EditBox"]:SetText(_G.GTipNotesDB[t] or "")

in the first chunk of code it is this one, this one says "frame" is a nil value
local region = GetNormalTexture(frame:GetRegions())

in the 2nd chunk of code im not sure which line it was i have to go back and check.
Unless you specifically declare a variable named this, any use of this is now invalid (and using it will cause nil errors). It's also not always just as simple as changing it to say self. That will usually work when you have a function definition of the form:
Code:
Frame:function()
Although even then, there can be problems. If your function is not declared like that (and the ones you posted aren't), you need to add a self parameter to the parameter list and update the code using the function to pass that along as well.

Note that if you add the parameter yourself, you don't have to call it self. You may use whatever name suits your fancy.
IQgryn is offline  
Unread 09-17-10, 10:18 AM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 9,624
You still have to define self with Frame:function() like so
Code:
Frame:function(self)
With the : notation, the frame reference is passed as the first argument (which you need to define with a variable if you wish to use it).
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

Seerah is offline  
Unread 09-17-10, 10:53 AM   #9
IQgryn
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 46
Originally Posted by Seerah View Post
You still have to define self with Frame:function() like so
Code:
Frame:function(self)
With the : notation, the frame reference is passed as the first argument (which you need to define with a variable if you wish to use it).
Actually, the self parameter is implied in that case. The only time you'd need to declare it specifically is if you called and/or defined it with a period instead of a colon. To quote myself from another thread:

Originally Posted by IQgryn View Post
These four code snippets are exactly the same thing with different syntax:

Code:
function MyAddon:MyFunc(var1) print(self, var1) end
MyAddon:MyFunc("test value")
Code:
function MyAddon.MyFunc(self, var1) print(self, var1) end
MyAddon.MyFunc(MyAddon, "test value")
Code:
function MyAddon:MyFunc(var1) print(self, var1) end
MyAddon.MyFunc(MyAddon, "test value")
Code:
function MyAddon.MyFunc(self, var1) print(self, var1) end
MyAddon:MyFunc("test value")
In other words:
When defining a function, if a colon is used, self will be the first parameter (before any others you list).
When calling a function, self is automatically passed (as the first argument) with the value of whatever is before the colon when you use a colon instead of a period.
This is nothing specific to WoW; all of Lua works this way to make object-oriented code easier to write.
IQgryn is offline  
Unread 09-17-10, 11:43 AM   #10
Vrul
A Cobalt Mageweaver
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 202
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.
Vrul is offline  
Unread 09-17-10, 11:43 AM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 9,624
Ah, yes, you're right. I was confusing Frame:function with Frame.function.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

Seerah is offline  
Unread 09-17-10, 11:53 AM   #12
IQgryn
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 46
Originally Posted by Seerah View Post
Ah, yes, you're right. I was confusing Frame:function with Frame.function.
Heh. I'll admit that I double-checked before contradicting you.
IQgryn is offline  
Unread 09-17-10, 06:00 PM   #13
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 975
Obi Vrul Kanobi, you were right on the friends list coloring. Something is amiss on the item boarder though still as well as the notes button. Just finally got into beta for some reason it was freezing up on the load screen for the last hour. heh.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
Grimsin is offline  
Unread 09-18-10, 12:53 AM   #14
Vrul
A Cobalt Mageweaver
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 202
For the item border code you need to make a similar change to the UpdateItemQualityBorders function:
lua Code:
  1. local function UpdateItemQualityBorders(frame, _, unit)
  2.     if frame.unit ~= unit then return end
  3.     local border = borders[frame]
  4.     for id = 1, #slots do
  5.         local link = GetInventoryItemLink(unit, id)                                         -- GetInventoryItemQuality doesn't work for InspectFrame
  6.         if link then
  7.             local color = qualityColor[link:match("|[Cc][Ff][Ff](%x%x%x%x%x%x)")]
  8.             border[id]:SetVertexColor(color[1], color[2], color[3])
  9.             border[id]:Show()
  10.         else
  11.             border[id]:Hide()
  12.         end
  13.     end
  14. end

For the notes code the OnAccept function should be:
lua Code:
  1. OnAccept = function(self)
  2.     addNoteFromPopup(_G[self:GetName() .. "EditBox"]:GetText())
  3. end,

Also, both EditBox functions have "_G[self:GetParent():GetName() .. 'EditBox']:GetText()" which is the same as "self:GetText()" so you may want to change that. However, I think that whole section of code could use some cleaning up:
lua Code:
  1. StaticPopupDialogs["GTipNotes"] = {
  2.     button1 = SET,
  3.     button2 = CANCEL,
  4.     hasEditBox = true,
  5.     hideOnEscape = true,
  6.     text = POPUP_TEXT,
  7.     timeout = 0,
  8.     whileDead = true,
  9.     EditBoxOnEnterPressed = function(self, data)
  10.         local note = self:GetText():trim()
  11.         if note == "" then
  12.             note = nil
  13.         end
  14.         GTipNotesDB[data] = note
  15.         self:GetParent():Hide()
  16.     end,
  17.     EditBoxOnEscapePressed = function(self)
  18.         self:GetParent():Hide()
  19.     end,
  20.     OnAccept = function(self, data)
  21.         local note = _G[self:GetName() .. 'EditBox']:GetText():trim()
  22.         if note == "" then
  23.             note = nil
  24.         end
  25.         GTipNotesDB[data] = note
  26.     end
  27. }
  28.  
  29. SlashCmdList["GTIPNOTES_SHORTHAND"] = function(note)
  30.     if UnitExists('target') then
  31.         local name = UnitName('target')
  32.         note = note:trim()
  33.         if note == "" then
  34.             note = GTipNotesDB[name]
  35.         end
  36.         StaticPopup_Show("GTipNotes", name, nil, name)
  37.         if note then
  38.             name = StaticPopup_Visible("GTipNotes")
  39.             if name then
  40.                 _G[name .. 'EditBox']:SetText(note)
  41.             end
  42.         end
  43.     else
  44.         print(TARGET_ERROR)
  45.     end
  46. end
Vrul is offline  
Unread 09-18-10, 10:17 AM   #15
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 122
Post

I wanted to ask. what i could do with this. as i felt that its about the same. the error i get is based on not being able to local the editbox no more for cata.;


Code:
		local editbox = _G[dialog:GetName().."WideEditBox"]  
		editbox:SetText(value)
		editbox:SetFocus()
		editbox:HighlightText()
thanks for your time,

i think i fixed it. was due to they re,pved WideEditBox/ as i see on an other post.
__________________
wMmap :: Is a lightweight Minimap, with a sleek look & custom imagery.
wIn1 :: In one addon. and is very lightweight & simple to use.
wChat :: Is a lightweight chat mod.
wPetXPBar :: Is A simple lightweight Pet XP Bar.

Last edited by weasoug : 09-18-10 at 10:36 AM.
weasoug is offline  
Unread 09-24-10, 10:18 AM   #16
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 975
Vrul - okay so remember you had said before i should remove the default db stuff which i did. I wonder if that is where i broke this? I have made all the changes you suggested and still get errors as far as it thinking the db is a nil value certain changes make that happen and certain things break the /commands. Im still really not understanding the use of _G now because almost everything that is broken, not just in the GrimUI has to do with _G. like baggins is borked and it has to do with the _G usage again and i just dont see why?

My entire move frames code is borked to in cata but im not even going there right now lol.

I also noticed something strange with the item coloring on the inspect window, when you inspect 2-3 items will have the boarder, then inspect again and more appear until you inspect like 3 times and they all are there then. Is this because of the inspect throttle stuff? Or some other problem?


The tipnotes looks like this, this is with all changes you have suggested including the one months ago about the default db not being stuffed into the base lua.

lua Code:
  1. local addonName, addon = ...
  2.  
  3. local DB_VERSION = 11
  4.  
  5. local defaultDatabase = nil
  6.  
  7. local POPUP_TEXT = "Set a note for |cffff4488%s|r."
  8. local TARGET_ERROR = "You must target something to add a note."
  9. local NOTE_SET = "Note for |cffff4488%s|r set to \"|cff888888%s|r\"."
  10. local SET = "Set"
  11. local CANCEL = "Cancel"
  12. local NOTE_PREFIX = "|cffff4488Note:|r "
  13. -- Keybinding to output the note to chat
  14. BINDING_HEADER_GRIMUI = "GrimUI"
  15. BINDING_NAME_GTIPNOTES_PRINT = "Print ToolTip Note"
  16.  
  17. function GTipNotes_GetNote(name)
  18.     if not name then return end
  19.     return _G.GTipNotesDB[name]
  20. end
  21.  
  22. local frame = CreateFrame("Frame")
  23. frame:SetScript("OnEvent", function()
  24.     if event == "VARIABLES_LOADED" then
  25.         if not _G.GTipNotesDB then
  26.             _G.GTipNotesDB = defaultDatabase
  27.             _G.GTipNotesDB.VERSION = DB_VERSION
  28.         end
  29.  
  30.         if not _G.GTipNotesDB.VERSION or _G.GTipNotesDB.VERSION < DB_VERSION then
  31.             for k, v in pairs(defaultDatabase) do
  32.                 if not _G.GTipNotesDB[k] then
  33.                     _G.GTipNotesDB[k] = v
  34.                 end
  35.             end
  36.             DEFAULT_CHAT_FRAME:AddMessage("|cffff4488Mob Notes|r database updated to revision " .. tostring(DB_VERSION) .. ".")
  37.             _G.GTipNotesDB.VERSION = DB_VERSION
  38.         end
  39.  
  40.         local orig = GameTooltip:GetScript("OnTooltipSetUnit")
  41.         GameTooltip:SetScript("OnTooltipSetUnit", function(tooltip, ...)
  42.             local name, unitid = tooltip:GetUnit()
  43.             if UnitExists(unitid) and _G.GTipNotesDB[name] then
  44.                 GameTooltip:AddLine(NOTE_PREFIX .. _G.GTipNotesDB[name], 0.5, 0.5, 0.5, 1)
  45.             end
  46.             return orig(tooltip, ...)
  47.         end)
  48.     end
  49. end)
  50.  
  51. frame:RegisterEvent("VARIABLES_LOADED")
  52.  
  53. local function addNoteFromPopup(note)
  54.     if type(note) ~= "string" or note:trim():len() == 0 then note = nil end
  55.     local t = UnitExists("target") and UnitName("target") or nil
  56.     if t then
  57.         _G.GTipNotesDB[t] = note
  58.         DEFAULT_CHAT_FRAME:AddMessage(NOTE_SET:format(t, tostring(note)))
  59.     end
  60. end
  61.  
  62. StaticPopupDialogs["GTipNotes"] = {
  63. button1 = SET,
  64. button2 = CANCEL,
  65. hasEditBox = true,
  66. hideOnEscape = true,
  67. text = POPUP_TEXT,
  68. timeout = 0,
  69. whileDead = true,
  70. EditBoxOnEnterPressed = function(self, data)
  71. local note = self:GetText():trim()
  72. if note == "" then
  73. note = nil
  74. end
  75. GTipNotesDB[data] = note
  76. self:GetParent():Hide()
  77. end,
  78. EditBoxOnEscapePressed = function(self)
  79. self:GetParent():Hide()
  80. end,
  81. OnAccept = function(self, data)
  82. local note = _G[self:GetName() .. 'EditBox']:GetText():trim()
  83. if note == "" then
  84. note = nil
  85. end
  86. GTipNotesDB[data] = note
  87. end
  88.  
  89. }
  90.  
  91. SlashCmdList["GTIPNOTES_SHORTHAND"] = function(note)
  92. if UnitExists('target') then
  93. local name = UnitName('target')
  94. note = note:trim()
  95. if note == "" then
  96. note = GTipNotesDB[name]
  97. end
  98. StaticPopup_Show("GTipNotes", name, nil, name)
  99. if note then
  100. name = StaticPopup_Visible("GTipNotes")
  101. if name then
  102. _G[name .. 'EditBox']:SetText(note)
  103. end
  104. end
  105. else
  106. print(TARGET_ERROR)
  107. end
  108. end
  109. _G.SLASH_GTIPNOTES_SHORTHAND1 = "/gtipnotes"
  110.  
  111.  
  112. end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
Grimsin is offline  
Unread 09-24-10, 07:04 PM   #17
Vrul
A Cobalt Mageweaver
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 202
Originally Posted by Grimsin View Post
I have made all the changes you suggested and still get errors as far as it thinking the db is a nil value certain changes make that happen and certain things break the /commands.
Because you didn't remove all of the db stuff, there is still some right in that code you posted.
Code:
local addonName, addon = ...

BINDING_HEADER_GRIMUI = "GrimUI"
BINDING_NAME_GTIPNOTES_PRINT = "Print ToolTip Note"
 
StaticPopupDialogs["GTipNotes"] = {
	button1 = "Set",
	button2 = "Cancel",
	hasEditBox = true,
	hideOnEscape = true,
	text = "Set a note for |cffff4488%s|r.",
	timeout = 0,
	whileDead = true,
	EditBoxOnEnterPressed = function(self, data)
		local note = self:GetText():trim()
		if note == "" then
			note = nil
		end
		GTipNotesDB[data] = note
		self:GetParent():Hide()
	end,
	EditBoxOnEscapePressed = function(self)
		self:GetParent():Hide()
	end,
	OnAccept = function(self, data)
		local note = _G[self:GetName() .. 'EditBox']:GetText():trim()
		if note == "" then
			note = nil
		end
		GTipNotesDB[data] = note
	end
}

SlashCmdList["GTIPNOTES_SHORTHAND"] = function(note)
	if UnitExists('target') then
		local name = UnitName('target')
		note = note:trim()
		if note == "" then
			note = GTipNotesDB[name]
		end
		StaticPopup_Show("GTipNotes", name, nil, name)
		if note then
			name = StaticPopup_Visible("GTipNotes")
			if name then
				_G[name .. 'EditBox']:SetText(note)
			end
		end
	else
		print("You must target something to add a note.")
	end
end
SLASH_GTIPNOTES_SHORTHAND1 = "/gtipnotes"

addon.RegisterEvent("TooltipNotes-Initialize", 'PLAYER_LOGIN', function(self, event)
	addon.UnregisterEvent(self, event)

	if type(GTipNotesDB) ~= 'table' then
		GTipNotesDB = { }
	end

	GameTooltip:HookScript('OnTooltipSetUnit', function(self)
		local note = GTipNotesDB[self:GetUnit()]
		if note then
			self:AddLine("|cffff4488Note:|r " .. note, 0.5, 0.5, 0.5, 1)
		end
	end)
end)

Originally Posted by Grimsin View Post
Im still really not understanding the use of _G now because almost everything that is broken, not just in the GrimUI has to do with _G. like baggins is borked and it has to do with the _G usage again and i just dont see why?

My entire move frames code is borked to in cata but im not even going there right now lol.
_G is just a table for the global namespace. Any error resulting from a line of code with _G[someVariableName] is because the object/value that has the name someVariableName on live in now gone, renamed, or significantly changed in beta. Pay attention to the error messages and check the values on the stack, this should easily get you to the relevant portion of Blizzard's code to track down the culprit.
Vrul is offline  
Unread 09-25-10, 06:36 PM   #18
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 975
how do we get into the new cata code? Is there an "addonkit" like for live wow where it decompiles the mpq's into readable lua's?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
Grimsin is offline  
Unread 09-25-10, 07:01 PM   #19
Starinnia
Ninja Code Monkey
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 84
Originally Posted by Grimsin View Post
how do we get into the new cata code? Is there an "addonkit" like for live wow where it decompiles the mpq's into readable lua's?
http://github.com/tekkub/wow-ui-source/tree/cat
Starinnia is offline  
 

Go BackWoWInterface » AddOns, Compilations, Macros » Cataclysm Beta » the _G changes.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off