WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   GetMapNameByID a nil value? (https://www.wowinterface.com/forums/showthread.php?t=56362)

eoblaed 07-17-18 05:26 PM

GetMapNameByID a nil value?
 
Fixing up some of the addons I use in the face of today's pre-patch release. So far, I'm batting a thousand, but coming across this error:
Code:

attempt to call global 'GetMapNameByID' (a nil value)
is a little problematic. I've looked up this API call here and it doesn't indicate it's moved 'tables' (like SendAddonMessage did).

Here's the top of the .lua file in question:
Code:

local addonName = ...
local addon = _G[addonName]
local colors = addon.Colors

local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
local BB = LibStub("LibBabble-Boss-3.0"):GetLookupTable()
local LCI = LibStub("LibCraftInfo-1.0")
local LCL = LibStub("LibCraftLevels-1.0")
local TS = addon.TradeSkills.Names

local SilMapName = GetMapNameByID(261)

Is there something else this file needs to allow it to get visibility of GetMapNameByID? (eg. in the C world, a #include, etc).

Thanks!

eoblaed 07-17-18 06:22 PM

Ok, so, after finding information at this git repo detailing what seems to be the current API, and this mapping of old IDs to the new format, it looks like I replace
Code:

GetMapNameByID(261)
With something like:
Code:

local SilMapDetails = C_Map.GetMapInfo(81)
local SilMapName = SilMapDetails.name

.. or some more condensed lua-ism (not very familiar with the language yet)

Seerah 07-17-18 08:16 PM

The whole map API changed with this patch. Typing "/api mapui" in-game will give you the user-friendly version of the Lua file you linked.

eoblaed 07-17-18 09:26 PM

Yeah, that's what led me down the path of finding the .lua file with the new API calls.

Unfortunately, I'm not finding a proper replacement for GetWorldMapTransforms(). This function resides in HereBeDragons, which is used by a lot of addons (including TomTom, HandyNotes, etc):
Code:

    local function processTransforms()
        wipe(transforms)
        for _, tID in ipairs(GetWorldMapTransforms()) do
            local terrainMapID, newTerrainMapID, _, _, transformMinY, transformMaxY, transformMinX, transformMaxX, offsetY, offsetX, flags = GetWorldMapTransformInfo(tID)
            -- flag 4 indicates the transform is only for the flight map
            if band(flags, 4) ~= 4 and (offsetY ~= 0 or offsetX ~= 0) then
                local transform = {
                    instanceID = terrainMapID,
                    newInstanceID = newTerrainMapID,
                    minY = transformMinY,
                    maxY = transformMaxY,
                    minX = transformMinX,
                    maxX = transformMaxX,
                    offsetY = offsetY,
                    offsetX = offsetX
                }
                table.insert(transforms, transform)
            end
        end
    en

Any clues?

dssd 07-17-18 09:31 PM

It's unclear what you're eventually trying to do with the transforms, but my guess is that C_Map.GetWorldPosFromMapPos and C_Map.GetMapPosFromWorldPos would the best replacements.

eoblaed 07-17-18 11:05 PM

I'm unclear as well. This is not code I wrote, it's part of an addon library that multiple addons use. I'm just trying to fix it in the face of the new API changes.

It would help if I knew what 'transforms' were in this context.

Those other calls you mentioned might be useful, except that this code is looping over a set of ids returned by GetWorlMapTransforms() (and then each id is fed to GetWorldMapTransformInfo() which gets us the various min/max/offset/etc data). It sounds like the GetWorldPosFromMapPos, et al, functions would be useful for that second step, but I'm not sure where to get the list of things to feed them.

If I knew what the ids represented that GetWorldMapTransforms() returned, that might help, but I can't find anything meaningful on that function anywhere. :(

Seerah 07-18-18 01:23 PM

Did you try an updated version of the library?
https://www.curseforge.com/wow/addons/herebedragons


All times are GMT -6. The time now is 01:39 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI