Download
(1 Kb)
Download
Updated: 09/25/23 04:58 AM
Compatibility:
base-game patch (9.1.5)
Updated:09/25/23 04:58 AM
Created:09/24/23 09:46 AM
Monthly downloads:89
Total downloads:853
Favorites:2
MD5:
AutoCollect
Version: 1.2
by: Kahanor [More]
With AutoCollect, items you loot are automatically added to your collection.

Install guide:

1.Install
2.Done
Optional Files (0)


Archived Files (2)
File Name
Version
Size
Uploader
Date
1.1
1kB
Kahanor
09/24/23 03:39 PM
1
1kB
Kahanor
09/24/23 09:46 AM


Post A Reply Comment Options
Unread 09/25/23, 02:12 AM  
Kahanor
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 1
Uploads: 1
Ok I will edit it then, thanks
Report comment to moderator  
Reply With Quote
Unread 09/24/23, 03:45 PM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 4993
File comments: 6047
Uploads: 78
Hello,

please do not create global functions or variables if not needed!
Put a local up in front of AutoCollectItem or else you might overwrite the same function name in any other addon!


Code:
-- Fonction pour lier un objet s'il n'est pas déjà lié
local function AutoCollectItem(bagId, slotIndex)

And:
Your addon's event EVENT_INVENTORY_SINGLE_SLOT_UPDATE is registered BEFORE your addon is actually loaded so it might error!
Please register events belonging to your addon AFTER your addon's EVENT_ADD_ON_LOADED was loaded properly, like this:


Lua Code:
  1. -- Enregistrez l'événement de chargement de l'interface utilisateur
  2. EVENT_MANAGER:RegisterForEvent("AutoCollect_OnLoad", EVENT_ADD_ON_LOADED,
  3.     function(eventCode, addOnName)
  4.         -- Vérifiez si c'est votre addon qui est chargé
  5.         if addOnName == "AutoCollect" then
  6.  
  7.             -- Enregistrez l'événement de ramassage d'objet
  8.             EVENT_MANAGER:RegisterForEvent("AutoCollect_OnItemAddedToInventory", EVENT_INVENTORY_SINGLE_SLOT_UPDATE,
  9.                function(eventCode, bagId, slotIndex, isNewItem, itemSoundCategory, updateReason)
  10.                  if isNewItem then
  11.                    AutoCollectItem(bagId, slotIndex)
  12.                 end
  13.             end)
  14.  
  15.             -- Configurez les gestionnaires d'événements
  16.             EVENT_MANAGER:UnregisterForEvent("AutoCollect_OnLoad", EVENT_ADD_ON_LOADED)
  17.         end
  18.     end)


Beside that you should use Event Filters instead of checking for the parameter in isNewItem in your event callback function for EVENT_INVENTORY_SINGLE_SLOT_UPDATE.
Here is the info about the Event Filters:
https://wiki.esoui.com/AddFilterForEvent
-> Check the "REGISTER_FILTER_IS_NEW_ITEM" filter

Event filters are done at C code of the game, before the lua code is even execute, so it's way more performant to skip those events for non-new items there already, instead of checking them at lua code for each item.
Last edited by Baertram : 09/24/23 at 03:47 PM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: