Destroying an item - Event questions
Hi,
as an item is selected to be destroyed the event EVENT_MOUSE_REQUEST_DESTROY_ITEM will fire. The parameters are: eventCode, bagId, slotIndex, itemCount, name, needsConfirm I registered a callback function for the event which is executing fine. I'm able to check the item which should be destroyed. If the item should not be destroyed you'll have to manually press "Abort" at the popup on screen. I'd like to do this automatically: Assuming I accidently try to destroy an item I want to keep, and I got some marker for this item to check, if the item should be kept. Questions: -Is there a possibility to disable the destruction popup asking me if I want to destroy the item? (Tried to play around with the parameter needsConfirm but it does not work as I thought) -Is there a way to keep the item, even if I press/choose "Yes" in the destruction popup? Did anyone play around with this already and got some ideas? Thanks for your help. Regards Baertram |
Try changing dialog button's callback:
Lua Code:
I couldn't find a way to get mainTextParams passed to the dialog. So I was thinking you could do your test in EVENT_MOUSE_REQUEST_DESTROY_ITEM and set a global g_allowDestroyItem flag, and use that to override what the OK button does. edit: if needsConfirm is true, it will fire a different dialog that requires you to type a word. Like when you want to delete a character, but I've never seen that with an item. edit2: perhaps it woud be best to suppress the "Destroy" option in context menu in the first place :) |
Thx for the input.
I think the function RespondToDestroyRequest is not working as it is private. But I'll test it. Edit: As I assumed it will raise an error because the function is private. Oh well, It seems I interpreted the needsConfirm parameter wrong then :) Disabling the destroy right-click menu pint is the next step. But you could easily drag&drop the item out of your inventory to destroy it too. So I'm currently focusing on this way. |
Quote:
Anyway, here's how you can hide "Destroy" action, should you want it. Change allowDestroyItem() to something useful, this one forbids destroying stacks of 2 items for illustration: Lua Code:
Edit 2: deleted malfunctioning code from my first attempt, this is much simpler and at least doesn't break putting items in bank :D |
Quote:
|
Quote:
|
Private means that the function is accessible from ESO code only. Not third party addons.
Protected means that you can only use a function in certain circumstances (like out of combat, for example, or in response to a hardware event). |
So I've come with two possible solutions, both of them a bit hacky.
This one replaces the "Yes" button with "Not really" button. I was not sure when exactly my EVENT_MOUSE_REQUEST_DESTROY_ITEM handler would be called (before or after the dialog is shown), so I override the button there and also in dialog's OnShow handler. Lua Code:
This one replaces the default EVENT_MOUSE_REQUEST_DESTROY_ITEM handler with one that shows a custom dialog on protected items: Lua Code:
|
Thx for the code merlight.
But both versions of your dialogs just change the buttons or dialog itsself. You wil lstill be able to press the primary and secondary keys of your keybindings to raise the Click event on button1 or button2, right? Yesterday I changed the destroy dialog so the "Yes" button is totally hidden for some items. But you were able to press the primary key so the OnClick() was executed. I changed the callback method of this Yes button then, returning nil or false. The items won't be destroyed anymore now :-) If you But the items remain in the "locked" state inside your inventory, because they were locked upon destroying. I can unlock them again by trying to destroy them and say no this time. Any1 got an idea how to unlock a locked item inside the inventory again? The event is EVENT_INVENTORY_ITEM_SLOT_UNLOCKED which will be normally called. Can I manually call it somehow in my dialog's callback function? |
The first variant replaces button text AND callback. Just tried that with a lockpick. If you see "/E/ Not really" and press /E/, nothing happens because the callback is replaced with the /Esc/ one.
The second variant shows a custom dialog, there is only one button and that does the /Esc/ action of the original destroy dialog, i.e. cancel destruction. It will probably make more sense if the button shows "/Alt/ Exit" instead of "/E/ OK" ... edited the above code to make it so. |
Quote:
Code:
text = SI_CHAT_DIALOG_CONFIRM_ITEM_DESTRUCTION, |
As Baertram wrote you cannot set (well you can but it will cause error)
Lua Code:
Lua Code:
|
Quote:
Code:
buttons = |
Alright merlight, thanks again.
Never thought of just replacing the callback of the "Yes" button with the callback of the "No" button :-) |
All times are GMT -6. The time now is 11:54 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI