Thread Tools Display Modes
07-17-18, 05:26 PM   #1
eoblaed
A Murloc Raider
 
eoblaed's Avatar
Join Date: Jul 2018
Posts: 7
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!
  Reply With Quote
07-17-18, 06:22 PM   #2
eoblaed
A Murloc Raider
 
eoblaed's Avatar
Join Date: Jul 2018
Posts: 7
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)
  Reply With Quote
07-17-18, 08:16 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
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.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-17-18, 09:26 PM   #4
eoblaed
A Murloc Raider
 
eoblaed's Avatar
Join Date: Jul 2018
Posts: 7
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?
  Reply With Quote
07-17-18, 09:31 PM   #5
dssd
A Fallenroot Satyr
Join Date: May 2016
Posts: 25
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.
  Reply With Quote
07-17-18, 11:05 PM   #6
eoblaed
A Murloc Raider
 
eoblaed's Avatar
Join Date: Jul 2018
Posts: 7
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.
  Reply With Quote
07-18-18, 01:23 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Did you try an updated version of the library?
https://www.curseforge.com/wow/addons/herebedragons
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » GetMapNameByID a nil value?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off