Page 1 of 1
[v1.3.0+] Enhanced Wield Replace
Posted: Tue May 20, 2014 3:57 am
by Zizzo
Urrgh... I still can't get this to work quite right, but I could use feedback on it, and maybe some help.
This addon is for the Rogues and Shadowblades that just found a cool new dagger to replace one of the ones they're wielding, or the Stone Wardens that want to swap in Titanic, or any character that just wants to replace one of their rings. Normally in a case like this, to make sure you're swapping out the one you mean to, you have to take that one off specifically before wielding the new item. This addon pops up a dialog to let you choose the one you want to swap out.
Now, I think I've got this mostly working; the wielded item goes to the right place, the replaced item properly goes back into inventory, nothing gets lost or duplicated (some of my early attempts at this were horrific...), monsters don't move until you're finished wielding, and you can cancel out of the dialog safely without using energy. The problem is that it leaves the inventory dialog in a bad state: Player:doWear() returns immediately thanks to the dialog before we can get around to wielding anything, and by that time, it's too late to tell the inventory dialog to update itself to reflect the changes. I haven't figured out the right combination of coroutines to get this to work; perhaps someone here whose Lua-fu is stronger than mine can tell me what I'm missing...
Since this is only a mostly functional addon, I'm not uploading it to the website yet; instead, I've attached it here. I believe the appropriate procedure is to rename the file from .zip to .teaa (the latter of which the forum squawks on, apparently) and stick it in your addons directory. And this comes with the usual
WARNING: I'm pretty sure this won't actually break anything, but don't use this on a character you'd really hate to lose.
Re: [v1.3.0+] Enhanced Wield Replace
Posted: Sun May 17, 2015 3:13 am
by Zizzo
And after further testing, I think I trust this addon enough now to
go live with it. I've added a few improvements since the testing version: the replacement candidates dialog now has a tooltip display for the selected item in the style of the inventory dialog, and you can even use <ctrl> to compare the selected item to the item you're about to wield.
NOTE: If you're using this addon in conjunction with
Enhanced Object Compare (directly or via
ZOmnibus), you'll want to upgrade it to the latest version (3b or 13d, respectively), which includes a fix to allow the above-mentioned <ctrl>-comparing.
[
Technical info:]
Code: Select all
Superload:
mod.class.Player:
doWear() [overloaded, to produce the candidates popup list as needed]
wearObject() [overloaded, to allow adding the object into a specific inventory position]
mod.dialogs.ShowEquipInven:
init() [to suppress on_select() tooltips if the candidates popup is up]
Re: [v1.3.0+] Enhanced Wield Replace
Posted: Tue Jan 26, 2016 12:06 am
by Zizzo
So, it turns out that way back in 1.3.0, the T4 module added functionality to the Player:doWear() method that would have made my job in this addon a
lot easier, and I was blindly clobbering it.

AFAICT this was in support of being able to mouse-drag an object from inventory onto whichever worn/wielded item you wanted to replace — which means that this addon was probably screwing that up.

That's fixed in release v1a, just pushed out. Also of note, Enhanced Wield Replace is now officially
included in ZOmnibus, for your convenience.

Re: [v1.3.0+] Enhanced Wield Replace
Posted: Tue Feb 02, 2016 3:41 am
by Zizzo
Fun fact: it turns out it is possible, as
Snow discovered, to attempt to wield an unwieldable object by dragging it around in the inventory dialog. Now, the game recovers from this gracefully — but it does so after the code added by this addon, which wasn't expecting that...

This is fixed in v1a.1, just pushed out.
Re: [v1.3.0+] Enhanced Wield Replace
Posted: Sat Jun 25, 2016 1:52 am
by Zizzo
So I recently noticed when trying to change my golem's gems that this addon's candidates list dialog doesn't get used, which is vaguely annoying now that I'm used to it. v1b, just pushed out, is an attempt to fix that. This involves moving the superload of :doWear() from mod.class.Player to mod.class.Actor; it's supposed to check that the actor is the player or the golem before kicking in, but let me know if you start getting prompted for which ring Urkis should swap out or something...

Re: [v1.3.0+] Enhanced Wield Replace
Posted: Mon Jun 11, 2018 1:05 am
by Zizzo
Déjà vu all over again…

Ran into the exact same problem as above trying to change weapons for my Writhing One's worm that walks (currently named Doug

). This may only kick in when manipulating its inventory via
Interact with the Worm, but it was easy enough to fix by slightly expanding the golem fix from before. That's pushed out as v1c.
Re: [v1.3.0+] Enhanced Wield Replace
Posted: Thu Jul 19, 2018 2:25 am
by Zizzo
And in using this with my worm that walks, I tripped over another wrinkle: I sized the replacement candidate dialog on the assumption that there would be only two candidates, but the worm that walks can wear four rings. They're all still choosable using the up/down arrow keys, but that's less than ideal, so I fixed it in v1c.1, just pushed out, to adjust the dialog height according to the number of candidates. As always, We Apologize for the Inconvenience.™
Re: [v1.3.0+] Enhanced Wield Replace
Posted: Wed Mar 11, 2020 3:38 am
by Zizzo
I keep running into this problem…

As with the
golem and the
worm that walks, the Annihilator's mecharachnid needs this dialog when swapping in new steamguns, so v1c.2 further expands the previous fixes to include it. I'd like for this to be extensible to addon-provided player sidekics like I did with
Enhanced Object Compare, but there's no obvious place to put a list of sidekick fields for addons to hook into; I may add one later if I think of something.
Re: [v1.3.0+] Enhanced Wield Replace
Posted: Sat Dec 05, 2020 7:33 pm
by Zizzo
Zizzo wrote:I'd like for this to be extensible to addon-provided player sidekics like I did with
Enhanced Object Compare, but there's no obvious place to put a list of sidekick fields for addons to hook into; I may add one later if I think of something.
Okay, thought of something.

Specifically, inspired by my
recent changes to Enhanced Object Compare, v1d.1 now makes our replacement candidates dialog available for any party member, which should buy us any future sidekick added by DLC or addons for free.
Re: [v1.3.0+] Enhanced Wield Replace
Posted: Sun May 19, 2024 4:21 pm
by Zizzo
Having added horizontal "ping-pong" scrolling to the attach-tinker dialog in
Tinkers for Sidekicks, it occurred to me that the sae feature would be useful in this addon's "which wielded thing do you want to replace with the thing you're about to wield?" dialog. That's going out as v1d.2:

- wield-pingpong.png (70.15 KiB) Viewed 5122 times
Re: [v1.3.0+] Enhanced Wield Replace
Posted: Mon Jun 24, 2024 9:21 pm
by Zizzo
Just ran into a bug in the wield-replace candidates dialog: you're supposed to be able to <ctrl>-compare the object you're trying to wield with the replace candidates in the candidates dialog, but it turns out I was doing that wrong.

That's fixed in v1d.3. We Apologize for the Error.™
Re: [v1.3.0+] Enhanced Wield Replace
Posted: Sat May 31, 2025 3:42 pm
by Zizzo
Dabbling with a
Mekurabe character from mannendake's
Youkai Pack addon, which, among other things, can't wear cloaks. I tried wearing the Cloak of Deception anyway, just to see what happened, and was faced with an empty list of replace candidates, which is obviously suboptimal. v1d.4 catches that case now.
(Actually, it turns out that the base game
doesn't handle that case too well, either; this release also adds a quick wrapper around ActorInventory:takeoffObject() to cover that.)