te4.org
Steam
EquipDoll - Clean Item Names
Moderator: Moderator
-
- Archmage
- Posts: 366
- Joined: Sat Dec 13, 2014 3:38 pm
Re: EquipDoll - Clean Item Names
Great little QoL addon. 

-
- Sher'Tul Godslayer
- Posts: 2521
- Joined: Thu Jan 23, 2003 8:13 pm
- Location: A shallow water area south of Bree
- Contact:
Re: EquipDoll - Clean Item Names
(Was going to PM this, but the send-a-private-message page apparently does not support attachments; We Apologize for the Inconvenience.™)
I hope that you're still maintaining this addon, because I'd like to suggest a (well, maybe not so) small revision:
As you may have noticed earlier, there was a conflict between your addon and my own Curse Levels addon (which is included in ZOmnibus, so a fair number of people tripped over it). The code causing the conflict is in your superloaded EquipDollFrame:drawShortItemName() method:
The problem is that that code doesn't do do what it looks like it does. The actual object table 'o' doesn't have a .getShortName field, so what you're assigning to 'temp' is the Object.getShortName method defined in mod/class/Object.lua. When you assign it back to o.getShortName, though, you're setting the field directly in the object table as an instance method — which superficially has the same effect, but that instance method will be saved to and loaded back from the savefile, which breaks superloading.
Now, I've added a workaround for the conflict to Curse Levels, but this could still cause conflicts with other addons, so I think it's still worth fixing. There are two approaches I can think of:
I hope that you're still maintaining this addon, because I'd like to suggest a (well, maybe not so) small revision:
As you may have noticed earlier, there was a conflict between your addon and my own Curse Levels addon (which is included in ZOmnibus, so a fair number of people tripped over it). The code causing the conflict is in your superloaded EquipDollFrame:drawShortItemName() method:
Code: Select all
local temp = o.getShortName
o.getShortName = o.getName
-- [...]
o.getShortName = temp
Now, I've added a workaround for the conflict to Curse Levels, but this could still cause conflicts with other addons, so I think it's still worth fixing. There are two approaches I can think of:
- Rather than manipulating the object directly, which is fraught with risks (ask me how I know…
), the approach I would suggest is to superload Object:getShortName() and have it divert to Object:getName() if it's called from EquipDollFrame:drawShortItemName(). I've attached a proof-of-concept implementation that appears to yield the same results as yours in testing, which I offer freely for your use.
- If you prefer to keep your code mostly unchanged, you should at least be using rawget() and rawset(). So your code would change to:
I'd also encourage you to wrap your call to the parent method in an xpcall(), so that even if the parent method throws an error, you can still clean up behind it. So this line:
Code: Select all
local temp = rawget(o, 'getShortName') rawset(o, 'getShortName', o.getName) -- [...] rawset(o, 'getShortName', temp)
would change to:Code: Select all
local ret = base( self, o, x, y )
and below where you restore all your saved original values, you'd add the line:Code: Select all
local ok, ret = xpcall(function() return base( self, o, x, y ) end, debug.traceback)
Code: Select all
if not ok then error(ret) end
- Attachments
-
- tome-clean_doll_z.zip
- (4.58 KiB) Downloaded 26 times
"Blessed are the yeeks, for they shall inherit Arda..."