Reply
Thread Tools Display Modes
Unread 07-22-14, 04:42 PM   #1
basvanderwerff
A Murloc Raider
Join Date: Jul 2014
Posts: 9
Looking for help with modifying code tooltip addon

Hello,

I recently found this addon that changes the (gear) item tooltips to the pre 5.1 look (specificly the order of the info) it works great but it has a few issues.
- I cant seam to find anyway to set it up beside toggle it on or off with /betteritemtooltip or /bitip (found these 2 / commands when looking trough the code) the addon page itself does not have any info beside that the addon reverts it back to pre 5.1 look
- enchants show in a light blue now i did find a list of text colors in the code and when i change:
enchantColor = { 0.0, 0.82, 1.0 } to enchantColor = { 0.0, 1.0, 0.0 } wich should be green since it used on the lfr heroic flex color codes nothing happens.
- pvp seasons text shows in red on wich i tried the same as with the enchants change the color code but also no luck.
- It messes with (some) non-gear tooltips from the TSM addon quick example
a crafted item typically shows this at bottom of a tooltip (i left some part out since tsm has alot of modules)
tradskillmaster info:
group: professions->inscription->crafts->glyph
auctions operation(s): glyph
TSM crafting:
Crafting cost: (price in gold-silver-copper)
Now for some items is still shows the colored part but the rest it removes for example it still show.
tradskillmaster info:
group:
auctions operation(s):
TSM crafting:
Crafting cost:
- somehow it removes the . in dmg numbers for example a 1.350.456 chaosbolt shows as 1350456 it also does the same on item tooltips (3.545 agi showing as 3545 agi) so guess they related and caused by this addon.

Now my question is.
1) How can i change the color of the enchant and season both to green in the code (or is there some ingame way to set this up i could not find)
2) Is there a way to stop this addon from messing with TSM tooltips
3) Is there a way to stop it from removing the . in dmg/stats numbers.

I added the lua file as attachement, hope someone can help out what to change in the code for changing the colors and maby point me in the right direction of what causes the TSM conflicts and the removeal of the . in dmg/stat numbers.

Thanks alot in advance, Bas.
Attached Files
File Type: lua Kopie van BetterItemTooltip.lua (56.7 KB, 23 views)
basvanderwerff is offline   Reply With Quote
Unread 07-25-14, 08:07 AM   #2
basvanderwerff
A Murloc Raider
Join Date: Jul 2014
Posts: 9
I think this is the part that removes the split in large number.
frame:SetScript("OnEvent", function(self, event, ...)
if (event == "VARIABLES_LOADED") then
self:UnregisterEvent("VARIABLES_LOADED");
self:RegisterEvent("CVAR_UPDATE");
if (GetCVarBool("breakUpLargeNumbers")) then
SetCVar("breakUpLargeNumbers", nil);
end
BetterItemTooltip:OnInitialize();
elseif (event == "CVAR_UPDATE") then
if (GetCVarBool("breakUpLargeNumbers")) then
SetCVar("breakUpLargeNumbers", nil);
end
end
basvanderwerff is offline   Reply With Quote
Unread 07-25-14, 09:52 AM   #3
myrroddin
Premium Member
 
myrroddin's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 373
That must be a very old AddOn. Almost nobody registers and uses VARIABLES_LOADED. Instead, if you need it check when entering the world OR every UI reload, PLAYER_ENTERING_WORLD is used. If you only need it to check one time, use PLAYER_LOGIN, do processing, and unregister PLAYER_LOGIN in the same function.

You could even use ADDON_LOADED, and handle it that way.

The trouble with VL, iirc, is that its load order is inconsistent.

Also, next time please use the [ code ] [ /code ] tags, or the # symbol in the tools above. You may have to change your WowI forum settings to get the full toolset to display. For your short piece of code, the quote is okay, I guess, but the formatting is ruined and makes it harder to read.

Last edited by myrroddin : 07-25-14 at 10:12 AM. Reason: ADDON LOADED
myrroddin is offline   Reply With Quote
Unread 07-25-14, 01:32 PM   #4
basvanderwerff
A Murloc Raider
Join Date: Jul 2014
Posts: 9
As far as i know it was made after 5.1 so not that old.
Thank you for the heads up on how to post code properly (i only recently found this forum)
I solved some of my initial problems with the addon.
1) i got the color of the enchant and season text changed to green turned out there was a saved variables file also and ONLY changing it both in the lua code and saved variables changed it.
2) I solved the problem with TSM addon by moving the TMS tooltip to a seperate window (option of TSM)

Now i just need to solve the problem of the addon removing the large number seperators wich it does everywhere from dmg/healing gold stats ect ect, ill repost the piece of code wich i think it the culprit.
Code:
frame:SetScript("OnEvent", function(self, event, ...)
	if (event == "VARIABLES_LOADED") then
		self:UnregisterEvent("VARIABLES_LOADED");
		self:RegisterEvent("CVAR_UPDATE");
		if (GetCVarBool("breakUpLargeNumbers")) then
			SetCVar("breakUpLargeNumbers", nil);
		end
		BetterItemTooltip:OnInitialize();
	elseif (event == "CVAR_UPDATE") then
		if (GetCVarBool("breakUpLargeNumbers")) then
			SetCVar("breakUpLargeNumbers", nil);
		end
	end
end);
frame:RegisterEvent("VARIABLES_LOADED");
And also looking trough the code it sugests that there are /commands to set these colors and hide/show various things in game but please correct me if im wrong, the second piece of code repeats itself for each different color setting there is available, can post that also if needed.
Code:
	SLASH_BETTERITEMTOOLTIP1 = "/betteritemtooltip";
	SLASH_BETTERITEMTOOLTIP2 = "/bitip";
end

function BetterItemTooltip:Print(...)
	if not (...) then return; end
	print("|cff4fcfffBetterItemTooltip:|r "..(...));
end

local options = {};
SlashCmdList.BETTERITEMTOOLTIP = function(msg)
	if not msg then return; end
	wipe(options);
	for v in gmatch(strlower(msg), "[^ ]+") do
		options[#options + 1] = v;
	end
	if options[1] == "bonuscolor" then
		if tonumber(options[2]) and tonumber(options[3]) and tonumber(options[4]) then
			local r, g, b = tonumber(options[2]), tonumber(options[3]), tonumber(options[4]);
			if r > 1 then r = 1; elseif r < 0 then r = 0; end
			if g > 1 then g = 1; elseif g < 0 then g = 0; end
			if b > 1 then b = 1; elseif b < 0 then b = 0; end
			db.bonusColor[1] = r;
			db.bonusColor[2] = g;
			db.bonusColor[3] = b;
			AvgItemLvl:Print("Bonus Stats Color is now "..format("|cff%02x%02x%02x%s, %s, %s|r", r*255, g*255, b*255, r, g, b));
After this it goes trough all the available color settings it ends with.
Code:
	elseif options[1] == "on" then
		db.enable = true;
		BetterItemTooltip:Print("BetterItemTooltip is now "..(db.enable and "|cff00ff00on|r" or "|cffff0000off|r"));
	elseif options[1] == "off" then
		db.enable = false;
		BetterItemTooltip:Print("BetterItemTooltip is now "..(db.enable and "|cff00ff00on|r" or "|cffff0000off|r"));
		for _, tooltip in pairs(tooltips) do
			if _G[tooltip] then
				tipIsShown = 1;
				ItemTooltip_OnHide(_G[tooltip]);
			end
		end
After this it goes trough a list of non color option for example show/hide made by tag on items ect ect they all listed in the same format but again can post them all if needed they look like this.
Code:
	elseif options[1] == "shortbonus" then
		db.shortBonus = not db.shortBonus;
		BetterItemTooltip:Print("Bonus Stats are now using "..(db.shortBonus and "|cff00ff00short|r" or "|cffff0000long|r").." format");
So i just like to know can i set all these options in game with /commands or do i need to change them in the code?
And can i get large number seperation back again.

Thanks alot in advance, bas.
basvanderwerff is offline   Reply With Quote
Unread 07-26-14, 02:27 AM   #5
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,282
Originally Posted by myrroddin View Post
That must be a very old AddOn. Almost nobody registers and uses VARIABLES_LOADED. ... The trouble with VL, iirc, is that its load order is inconsistent.
The trouble with VARIABLES_LOADED is that it can fire many times during the loading sequence, including before your addon's saved variables have been loaded. Its purpose is to inform the WoW client that some of its own settings (eg. Interface Options settings, key bindings, possibly action button assignment data from server?) have been loaded; it has not been an appropriate event for addon initialization since sometime back in the Burning Crusade. Either this addon is ancient, or its author found the most outdated resource on the entire internet to look at when they were developing it...

Originally Posted by basvanderwerff View Post
Now i just need to solve the problem of the addon removing the large number seperators wich it does everywhere from dmg/healing gold stats ect ect, ill repost the piece of code wich i think it the culprit.
Based on the code you posted, you should just be able to remove that entire chunk (or just comment it out) to stop the addon from stopping large numbers from behing formatted. Afterwards you may need to restore the CVar:

/run SetCVar("breakUpLargeNumbers", 1)

I'm not even sure why the addon is overriding this, as I'm pretty sure there aren't even any numbers in item tooltips that are long enough to qualify for break-up. Sounds like feature creep.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 07-26-14, 03:13 AM   #6
ObbleYeah
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 136
Originally Posted by Phanx View Post
The trouble with VARIABLES_LOADED is that it can fire many times during the loading sequence, including before your addon's saved variables have been loaded. Its purpose is to inform the WoW client that some of its own settings (eg. Interface Options settings, key bindings, possibly action button assignment data from server?) have been loaded; it has not been an appropriate event for addon initialization since sometime back in the Burning Crusade. Either this addon is ancient, or its author found the most outdated resource on the entire internet to look at when they were developing it...
I think either ElvUI or Aurora uses it liberally.
ObbleYeah is offline   Reply With Quote
Unread 07-26-14, 05:06 AM   #7
myrroddin
Premium Member
 
myrroddin's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 373
Originally Posted by ObbleYeah View Post
I think either ElvUI or Aurora uses it liberally.
I can understand ElvUI using VARIABLES_LOADED when setting up the UI's "Set CVars" option, but that is still awkward.

I don't see why Aurora would use it, however.

In either case, Phanx (as usual) explained the issue with registering that event better than I, or most people.

If you are rewriting an AddOn, use ADDON_LOADED instead, and save yourself and your users a whole lot of pain.

As for my previous post, on second thought, don't use PLAYER_LOGIN, as that can fire when you have logged in, but are not actually in the game world, and thus your AddOn is not fully loaded in terms of frames, scripts, possibly saved variables, etc.

Not that I've tested, but I wouldn't put it past Blizzard to make PL depreciated for AddOns, and make it exclusive to the BattleNet desktop app. You know that message where your friend Bob has logged into the app, but hasn't logged into a game? Yeah, I can see Blizzard doing something sneaky like that.
myrroddin is offline   Reply With Quote
Unread 07-27-14, 04:09 AM   #8
basvanderwerff
A Murloc Raider
Join Date: Jul 2014
Posts: 9
Originally Posted by Phanx View Post
I'm not even sure why the addon is overriding this, as I'm pretty sure there aren't even any numbers in item tooltips that are long enough to qualify for break-up. Sounds like feature creep.
I think cause those large numbersperators also got added in 5.1 but it just a quess since the addon discription only said restores the tooltips to pre 5.1.
Anyway ill give removing that piece of code a go and see if that does the trick.

Bases on the other code i linked is it possible to change settings in game beside toggle it on or off?
basvanderwerff is offline   Reply With Quote
Unread 07-27-14, 05:38 AM   #9
Haleth
This Space For Rent
 
Haleth's Avatar
WoWInterface Super Mod
Featured
Join Date: Sep 2008
Posts: 1,168
Originally Posted by ObbleYeah View Post
I think either ElvUI or Aurora uses it liberally.
Aurora doesn't use it, though by all means, none of the code in there should be considered an example of how to write good addons It's long overdue for a big rewrite. The core is fine but after that it gets a bit messy.

On topic:

It looks like /betteritemtooltip is a /command you can use to set some of the options. They're all listed in there - bonuscolor, enchantcolor, etc - but it seems like there's no easy way to get a tutorial or anything.
Haleth is offline   Reply With Quote
Unread 07-27-14, 06:20 AM   #10
basvanderwerff
A Murloc Raider
Join Date: Jul 2014
Posts: 9
Originally Posted by Haleth View Post
On topic:

It looks like /betteritemtooltip is a /command you can use to set some of the options. They're all listed in there - bonuscolor, enchantcolor, etc - but it seems like there's no easy way to get a tutorial or anything.
When i use either /betteritemtooltip or /bitip it either turns the addon on or off and post in chat either.
Betteritemtooltip: betteritemtooltip is now on
Betteritemtooltip: betteritemtooltip is now off

Ok so i found them typing:
/bitip list give a list of all how the settings are atm and
/bitip reforged toggles showing reforge on/off this works for all the toggle settings
/bitip ilvlcolor 0, 1, 0, changed the ilvlcolor to green and /bitip ilvlcolor 1, 1, 1, changes it back to white all those color change commands sometimes work and sometimes need to be done couple of times before it actually works but the toggle show/hide coomands work each time and that most important.

Last edited by basvanderwerff : 07-27-14 at 06:41 AM. Reason: Finally found the ingame commands
basvanderwerff is offline   Reply With Quote
Unread 07-28-14, 03:53 AM   #11
basvanderwerff
A Murloc Raider
Join Date: Jul 2014
Posts: 9
Ok i tried to remove that whole bit of code:
Code:
frame:SetScript("OnEvent", function(self, event, ...)
	if (event == "VARIABLES_LOADED") then
		self:UnregisterEvent("VARIABLES_LOADED");
		self:RegisterEvent("CVAR_UPDATE");
		if (GetCVarBool("breakUpLargeNumbers")) then
			SetCVar("breakUpLargeNumbers", nil);
		end
		BetterItemTooltip:OnInitialize();
	elseif (event == "CVAR_UPDATE") then
		if (GetCVarBool("breakUpLargeNumbers")) then
			SetCVar("breakUpLargeNumbers", nil);
		end
	end
end);
frame:RegisterEvent("VARIABLES_LOADED");
But will stop the addon from working all together how about i change both bits of code that say:
SetCVar("breakUpLargeNumbers", nil)
to
SetCVar("breakUpLargeNumbers", 1)
whould that work?

Also you guys said VARIABLES_LOADED not work great is it fine to replace it with ADDON_LOADED or whould i need to change more code.

Last edited by basvanderwerff : 07-28-14 at 03:57 AM.
basvanderwerff is offline   Reply With Quote
Unread 07-29-14, 03:20 AM   #12
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,282
Originally Posted by basvanderwerff View Post
Ok i tried to remove that whole bit of code ... But will stop the addon from working all together how about i change both bits of code that say:
SetCVar("breakUpLargeNumbers", nil)
to
SetCVar("breakUpLargeNumbers", 1)
whould that work?
What was the error message after you removed that block?

Originally Posted by basvanderwerff View Post
Also you guys said VARIABLES_LOADED not work great is it fine to replace it with ADDON_LOADED or whould i need to change more code.
Just change VARIABLES_LOADED to PLAYER_LOGIN.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 07-29-14, 01:24 PM   #13
basvanderwerff
A Murloc Raider
Join Date: Jul 2014
Posts: 9
Originally Posted by Phanx View Post
What was the error message after you removed that block?
No error at all it whould just not load at all not even after restarting WoW completely.
basvanderwerff is offline   Reply With Quote
Unread 07-29-14, 02:36 PM   #14
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,282
Any time something "doesn't work" there is an error being raised. If you don't already have BugSack or Swatter installed, go install BugSack. The default error display is incapable of showing errors that happen during the initial loading process, but that's where most of the errors occur during development, so it's basically useless... actually worse than useless, since it gives the false impression that nothing is wrong.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 07-30-14, 03:42 PM   #15
basvanderwerff
A Murloc Raider
Join Date: Jul 2014
Posts: 9
24x !BetterItemTooltip-1.1.1\BetterItemTooltip.lua:1004: attempt to index upvalue "db" (a nil value)
!BetterItemTooltip-1.1.1\BetterItemTooltip.lua:1004: in function <!BetterItemTooltip\BetterItemTooltip.lua:1003>
<in C code>
<in C code>
TradeSkillMaster-v2.9.1\Libs\LibExtraTip\LibExtraTip.lua:432: in function <TradeSkillMaster\Libs\LibExtraTip\LibExtraTip.lua:426>
<in C code>
TradeSkillMaster-v2.9.1\Libs\LibExtraTip\LibExtraTip.lua:387: in function "SetInventoryItem"
FrameXML\PaperDollFrame.lua:2486: in function "PaperDollItemSlotButton_OnEnter"
<string>:"*:OnEnter":1: in function <string>:"*:OnEnter":1

Locals:
(*temporary) = <function> defined =[C]:-1
= <function> defined *:OnTooltipSetItem:1
= <function> defined @Interface\AddOns\!BetterItemTooltip\BetterItemTooltip.lua:1003

This is what bugsack gave me after deleting this code block i linnked before.
Code:
frame:SetScript("OnEvent", function(self, event, ...)
	if (event == "VARIABLES_LOADED") then
		self:UnregisterEvent("VARIABLES_LOADED");
		self:RegisterEvent("CVAR_UPDATE");
		if (GetCVarBool("breakUpLargeNumbers")) then
			SetCVar("breakUpLargeNumbers", nil);
		end
		BetterItemTooltip:OnInitialize();
	elseif (event == "CVAR_UPDATE") then
		if (GetCVarBool("breakUpLargeNumbers")) then
			SetCVar("breakUpLargeNumbers", nil);
		end
	end
end);
frame:RegisterEvent("VARIABLES_LOADED");
basvanderwerff is offline   Reply With Quote
Unread 07-30-14, 03:47 PM   #16
semlar
A Molten Giant
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 551
Try this instead..
Lua Code:
  1. frame:SetScript("OnEvent", function(self, event, ...)
  2.     if ... == addonName then
  3.         BetterItemTooltip:OnInitialize()
  4.     end
  5. end)
  6. frame:RegisterEvent("ADDON_LOADED")

Last edited by semlar : 07-30-14 at 03:58 PM.
semlar is online now   Reply With Quote
Unread 08-03-14, 04:16 AM   #17
basvanderwerff
A Murloc Raider
Join Date: Jul 2014
Posts: 9
Putting in
Code:
frame:SetScript("OnEvent", function(self, event, ...)
    if ... == addonName then
        BetterItemTooltip:OnInitialize()
    end
end)
frame:RegisterEvent("ADDON_LOADED")
did the trick no errors or anything after that i ran

/run SetCVar("breakUpLargeNumbers", 1)
Now the addon works and it wont mess with large numbers anymore.

Thanks alot for those that helped to get it working good.
basvanderwerff is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » Looking for help with modifying code tooltip addon

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