View Single Post
05/24/23, 04:11 AM   #7
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,001
You should not use the fixed numbers 0 ,1 and 2 etc. but the constants the game provides.
The constants type used for any API function or event are provided at the API documentation txt file:

Code:
* EVENT_CRAFTING_STATION_INTERACT (*[TradeskillType|#TradeskillType]* _craftSkill_, *bool* _sameStation_, *[CraftingInteractionMode|#CraftingInteractionMode]* _craftMode_)
Search for TradeskillType in the same txt filet o get the possible constants:
Code:
h5. TradeskillType
* CRAFTING_TYPE_ALCHEMY
* CRAFTING_TYPE_BLACKSMITHING
* CRAFTING_TYPE_CLOTHIER
* CRAFTING_TYPE_ENCHANTING
* CRAFTING_TYPE_INVALID
* CRAFTING_TYPE_JEWELRYCRAFTING
* CRAFTING_TYPE_PROVISIONING
* CRAFTING_TYPE_WOODWORKING

You will find those constants and their values via merTorchbug ingame too, using /tb and then click on the constants tab (search is top left).
e.g. enter CRAFTING_ and it should list all + their values.

Better use those as the numbers MIGHT (did) change in the future and 0 will stay 0 but CRAFTING_TYPE_INVALID might change to soemthing like -1 or similar and break your code then!

This applies to all API functions and events and callbacks.




Originally Posted by ExoY View Post
you can also just register the same event multiple times for different features
Yes, only make sure to change the unique eventName "MyAddon" you specify to really be unique or you just overwrite your event callback!


Code:
EVENT_MANAGER:RegisterForEvent("MyAddon" .. tostring(craftingType), ...
btw: "MyAddon" (if you really use that in your addon RidinDirty as the unique event name) is not unique enough!
You might break other addons using the same.
!!!Please change that at ALL events in your addons to use a really unique name, like YOUR addon's real name, and not a generic "My Addon" or similar !!!
e.g. use RidinDirty.name if this exists

Last edited by Baertram : 05/24/23 at 04:15 AM.
  Reply With Quote