Thread Tools Display Modes
06-11-13, 04:14 PM   #1
kamuul
A Murloc Raider
Join Date: Jun 2013
Posts: 4
[Request] Addon to change some spells descriptions/name in tooltip

Hi!

First of all, I'm sorry for my bad english =(
I'm looking for an addon that change some spell descriptions/name in tooltip. I want an addon who can show something like this:

Without the addon
Code:
Healing Touch
28.9% of base mana
Heals a friendly target for 18460 to 21800
With the addon
Code:
Heal a friend
28.9% of base mana
You heals your friend for 18460 to 21800. Your friend will be very thankful!
I want to modify a lot of spells. I see this addon: http://www.wowinterface.com/download...ranslator.html, doing a sightly different thing (it translates the tooltip) but that maybe inspire you!

I hope your answers!
  Reply With Quote
06-11-13, 06:03 PM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Lua Code:
  1. local str = "Heals a friendly target for (%d+) to (%d+)"
  2. local newStr = "You heals your friend for $1 to $2. Your friend will be very thankful!"
  3.  
  4. GameTooltip:HookScript('OnShow', function(self)
  5.     for index = 1, self:NumLines() do
  6.         local line = _G['GameTooltipTextLeft' .. index]
  7.         local text = line:GetText()
  8.         if(string.match(text, str)) then
  9.             line:SetText(string.gsub(text, str, newStr))
  10.         end
  11.     end
  12. end)

Something like this would work, syntax is probably way off and only works for one string, a table refering would probably be optimal, as well as some more checks than just the string to avoid lookups.
  Reply With Quote
06-11-13, 06:05 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'm not sure how adding more meaningless text to the tooltip makes it more readable or more useful, but here you go:

Code:
local patterns = {
    ["Heals a friendly target for (%d+) to (%d+)."] = "You heal your friend for %1 to %2. Your friend will be very thankful!",
}

GameTooltip:HookScript("OnTooltipSetSpell", function(self)
    for i = 3, self:NumLines() do
        local line = _G["GameTooltipTextLeft"..i]
        local text = line:GetText()
        for k, v in pairs(patterns) do
            text = gsub(text, k, v)
        end
        line:SetText(text)
    end
    self:Show()
end)
Add more patterns as desired.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
06-11-13, 06:11 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Phanx View Post
I'm not sure how adding more meaningless text to the tooltip makes it more readable or more useful, but here you go:\
I'm pretty sure it's just for flavor and/or RP purposes.
__________________
"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

  Reply With Quote
06-12-13, 05:01 AM   #5
kamuul
A Murloc Raider
Join Date: Jun 2013
Posts: 4
Hi! Thank you very much for your answer!

Indeed, it is for RP purposes.

p3lim, thank you so much! Like you say, I want it to work for more string. However, thank you!

Phanks, about your code, in order to add more patterns, it is something like this to use it with more spells?

Code:
local patterns = {
    ["Heals a friendly target for (%d+) to (%d+)."] = "You heal your friend for %1 to %2. Your friend will be very thankful!",
    ["Returns the spirit to the body."] = "Order your friend to come back to life!",
}
Can i use this code to change spellnames too?

Thank you again!
  Reply With Quote
06-12-13, 07:25 AM   #6
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Correct, and phanx's stuff is more or less the same that I made.
And yes, that's how you would add more.

In order to include the spellname, I'd probably change the code up a bit to check for actual spellID or real spellNames (just for safety), but you can change this in phanx's code:

Code:
for i = 3, self:NumLines() do
into
Code:
for i = 1, self:NumLines() do
  Reply With Quote
06-12-13, 07:33 AM   #7
kamuul
A Murloc Raider
Join Date: Jun 2013
Posts: 4
Nice! I'll change it.

Again, thank you very much!!!!
  Reply With Quote
06-12-13, 10:01 AM   #8
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
I wonder, would it not be more efficient if replacement texts were bound to spellid for strings that are not ambiguous in any way? Assuming I want to translate "Call Pet 1" to dutch:

lua Code:
  1. local spellNames = {
  2.     [883] = "Roep Waakdier 1"
  3. }
  4. local spellDescriptions = {
  5.     [883] = "Roept je eerste waakdier op."
  6. }
Then, you can use the spellId(tooltip:GetSpell()) to replace the values.

Offcourse, for spells that have a generic description, such as parry or strings such as "Item Level (%d+)", a generic replacement table is better.

Last edited by ravagernl : 06-12-13 at 10:11 AM.
  Reply With Quote
06-12-13, 01:35 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by ravagernl View Post
I wonder, would it not be more efficient if replacement texts were bound to spellid for strings that are not ambiguous in any way? Assuming I want to translate "Call Pet 1" to dutch:

lua Code:
  1. local spellNames = {
  2.     [883] = "Roep Waakdier 1"
  3. }
  4. local spellDescriptions = {
  5.     [883] = "Roept je eerste waakdier op."
  6. }
Then, you can use the spellId(tooltip:GetSpell()) to replace the values.
Given the number of spells that share the same name (eg. there are about 30 spells named "Mortal Strike") it would probably be more efficient to use the "real" name as the key:

Code:
local spellNames = {
    [(GetSpellInfo(883))] = "Roep Waakdier 1"
}
And for any text that includes values (damage, healing, number of debuffs dispelled, length of time, etc.) you would still need to use pattern matching, so again, you might as well just key off the text, since the vast majority of text found in spell tooltips can be generalized into a handful of patterns.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
06-12-13, 04:40 PM   #10
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
I didn't think it was this straight forward to modify the tooltip.
__________________
Tweets YouTube Website
  Reply With Quote
06-23-13, 05:25 AM   #11
kamuul
A Murloc Raider
Join Date: Jun 2013
Posts: 4
Hi again!

I've been testing what all of you write for me, and finally, I think this code (by Treeston) fits better what I'm looking for, but I still have some problems:
-It doesn't change the spellname shown in the talent panel
-I want to change the name shown in the castbar and buff bar
-I have problems with big spell descriptions, it doens't works very well (spells like "Heart of the wild" or "Solace and insanity")

Would you help me again, please?

Thank you again!

Lua Code:
  1. local tooltips = {"GameTooltip"}
  2. local replacedSpells = {
  3.     [108238] = { -- SpellID
  4.         "Big heal", -- New name
  5.         "Instantly heals the Druid for 30%% of maximum health.  Useable in all shapeshift forms.", -- Pattern to match against old tooltip
  6.         "Heals you a lot. Use it while in bear form for better results.", -- Formatstring for new tooltip
  7.     },
  8. }
  9.  
  10. local ifformat = function(fstring, ...)
  11.     if (...) then
  12.         return fstring:format(...)
  13.     end
  14. end
  15.  
  16. local trigger = function(self)
  17.     local _,_,id = self:GetSpell()
  18.     if not id then return end
  19.     local data = replacedSpells[id]
  20.     if not data then return end
  21.     local n = self:GetName()
  22.     local t1 = _G[("%sTextLeft1"):format(n)]
  23.     if t1 then t1:SetText(data[1]) end
  24.     local i = 2
  25.     local t2 = _G[("%sTextLeft%d"):format(n,i)]
  26.     while t2 do
  27.     local t2t,m = (t2:GetText())
  28.         if t2t then
  29.             m = ifformat(data[3],t2t:match(data[2]))
  30.         end
  31.         if m then
  32.             t2:SetText(m)
  33.             break
  34.         end
  35.         i=i+1
  36.         t2 = _G[("%sTextLeft%d"):format(n,i)]
  37.     end
  38. end
  39.  
  40. for _,tooltipName in ipairs(tooltips) do
  41.     local t = _G[tooltipName]
  42.     if t then
  43.         t:SetScript("OnTooltipSetSpell",trigger)
  44.     else
  45.         print(("Tooltip does not exist: %s"):format(tooltipName))
  46.     end
  47. end
  48.  
  49. hooksecurefunc("SpellButton_UpdateButton",function(s) -- next code change spellname shown in spellbook
  50.     local _,_,id = SpellBook_GetSpellBookSlot(s)
  51.     local data = replacedSpells[id]
  52.     if data then
  53.         _G[("%sSpellName"):format(s:GetName())]:SetText(data[1])
  54.     end
  55. end)
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » [Request] Addon to change some spells descriptions/name in tooltip


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