Add New Code in New File to Existing Addon
I have several addons that still use the old GetMapNameByID() API call. This is now a 'nil'.
I wrote a thin wrapper function that looks up the old worldID, converts it to the new style UiMapID, and returns C_Map.GetMapInfo(newid).name. The code works when I embed it directly into the various .lua files of the addon (but, that's not a great solution). What I'm trying to do is create a new file, MapCompat.lua, in such a way that will allow the other pre-existing lua files in the addon to see the GetMapNameByID() call in that new .lua file. Not having authored an addon before, there's a seemingly labyrinthine combination of .xml, .toc, etc, and I haven't quite hit on the right combination of things to do what I want to do. Any pointers? Thanks! |
No need to change or mess with any addons. If what you have works, just make a separate addon with the code and all addons will see it. You may have to name the addon with a ! in front to make sure it loads first. Those functions are global objects, so addons will see your change.
To make it even simpler, go to https://addon.bool.no, paste your code, and unzip it like any other addon. |
Also, for future reference, if you want to pass information between modules (.lua files) within the same addon, each .lua file is "passed" two parameters, the name of the addon and a table that is exlcusive to that addon.
To use them, at the top of each file add Code:
local addonName, addonTable = ... You can create a function Code:
function addonTable:GetMapNameByID() Code:
addonTable:GetMapNameByID() |
Thanks for the responses!
I've got things working now with the 'make an addon with the functions I'd like to be global' approach. I wasn't aware the scoping was that permissive. It's working now, though. Thanks! |
All times are GMT -6. The time now is 06:39 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI