ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Wed Dec 13, 2017 8:36 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue May 20, 2014 3:57 am 
Offline
Sher'Tul

Joined: Thu Jan 23, 2003 8:13 pm
Posts: 1413
Location: A shallow water area south of Bree
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... :oops:

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.


Attachments:
tome-wield-replace.zip [3.92 KiB]
Downloaded 48 times

_________________
"Blessed are the yeeks, for they shall inherit Arda..."


Last edited by Zizzo on Sun May 17, 2015 3:14 am, edited 1 time in total.
Top
 Profile  
 
PostPosted: Sun May 17, 2015 3:13 am 
Offline
Sher'Tul

Joined: Thu Jan 23, 2003 8:13 pm
Posts: 1413
Location: A shallow water area south of Bree
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:
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]

_________________
"Blessed are the yeeks, for they shall inherit Arda..."


Top
 Profile  
 
PostPosted: Tue Jan 26, 2016 12:06 am 
Offline
Sher'Tul

Joined: Thu Jan 23, 2003 8:13 pm
Posts: 1413
Location: A shallow water area south of Bree
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. :oops: 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. :oops: :oops: That's fixed in release v1a, just pushed out. Also of note, Enhanced Wield Replace is now officially included in ZOmnibus, for your convenience. :wink:

_________________
"Blessed are the yeeks, for they shall inherit Arda..."


Top
 Profile  
 
PostPosted: Tue Feb 02, 2016 3:41 am 
Offline
Sher'Tul

Joined: Thu Jan 23, 2003 8:13 pm
Posts: 1413
Location: A shallow water area south of Bree
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... :oops: This is fixed in v1a.1, just pushed out.

_________________
"Blessed are the yeeks, for they shall inherit Arda..."


Top
 Profile  
 
PostPosted: Sat Jun 25, 2016 1:52 am 
Offline
Sher'Tul

Joined: Thu Jan 23, 2003 8:13 pm
Posts: 1413
Location: A shallow water area south of Bree
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... :shock: :oops:

_________________
"Blessed are the yeeks, for they shall inherit Arda..."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group