Quantcast
WoWInterface - View Single Post - Error when using GetMapInfo
View Single Post
08-25-18, 10:17 AM   #1
Yukyuk
A Chromatic Dragonspawn
 
Yukyuk's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2015
Posts: 176
Error when using GetMapInfo

I recently updated my addon Historia to BFA.
All is working fine but there is one error I can't solve.
Its when I get a loading screen and then end up in a zone I haven't been before.
I get an error.

Lua Code:
  1. 20x FrameXML\MapUtil.lua:11: Usage: local info = C_Map.GetMapInfo(uiMapID)
  2. [C]: in function `GetMapInfo'
  3. FrameXML\MapUtil.lua:11: in function `GetMapParentInfo'
  4. Historia\HistoriaMain.lua:326: in function `?'
  5. Historia\HistoriaMain.lua:146: in function <Historia\HistoriaMain.lua:145>
  6.  
  7. Locals:
  8. (*temporary) = nil


I understand the error but what I do not ouderstand is WHY I am getting it.
If statement in line 11 (line 326 in the full addon) should prevent it.
When executing the addon it will print the currentMapId as being nil
and it will print the number 1.

Think I must be missing something here

Lua Code:
  1. function private_table.eventFrame:UI_INFO_MESSAGE(...)
  2.     local arg1, arg2 = ...
  3.     --print(arg1)
  4.     --print(arg2)
  5.     addon:Check_Dates()
  6.     if arg1 == 371 then
  7.         local zone = {}
  8.         zone.time = time()
  9.         local currentMapId, TOP_MOST = C_Map.GetBestMapForUnit('player'), true
  10.         print(currentMapId)
  11.         if currentMapId == nil then
  12.             print("1")
  13.             local zone = {}
  14.         else
  15.             print("2")
  16.             local currentContinentInfo = MapUtil.GetMapParentInfo(currentMapId, Enum.UIMapType.Continent, TOP_MOST)
  17.             print(currentContinentInfo)
  18.             zone.continent = currentContinentInfo.name
  19.             zone.zoneName = GetZoneText()
  20.             zone.subzoneName = GetSubZoneText()
  21.             table.insert(HistoriaLocalDb.Area, zone)
  22.             --  Insert new area in the dates table
  23.             table.insert(HistoriaLocalDb.Dates[addon.YS][addon.MS][addon.DS].Area, zone)
  24.         end
  25.     elseif arg1 == 280 then
  26.         local flight = {}
  27.         flight.time = time()       
  28.         local currentMapId, TOP_MOST = C_Map.GetBestMapForUnit('player'), true
  29.         local currentContinentInfo = MapUtil.GetMapParentInfo(currentMapId, Enum.UIMapType.Continent, TOP_MOST)
  30.         flight.continent = currentContinentInfo.name       
  31.         flight.zoneName = GetZoneText()
  32.         flight.subzoneName = GetSubZoneText()
  33.         table.insert(HistoriaLocalDb.Taxi, flight)
  34.         --  Insert new flight path in the dates table
  35.         table.insert(HistoriaLocalDb.Dates[addon.YS][addon.MS][addon.DS].Taxi, flight) 
  36.     end    
  37. end
__________________
Better to fail then never have tried at all.
  Reply With Quote