WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   function to switch from one map to another? (https://www.wowinterface.com/forums/showthread.php?t=59688)

Ssesmar 10-15-23 02:29 AM

function to switch from one map to another?
 
Hey, i'm trying to edit my addon but I'm stuck right now. For example, the addon shows dungeon entrances that can be clicked on so that the journal with the corresponding dungeon opens. This works perfectly, but when I try to add a staircase/exit symbol to a dungeon map, such as on the map of the Ruby Life Pools from the infusion chambers to the ruby ​​control room, it works not.

function pluginHandler:OnClick(button, pressed, uiMapId, coord)
if (button == "LeftButton" and db.journal) then
if (not EncounterJournal_OpenJournal) then
UIParentLoadAddOn('Blizzard_EncounterJournal')
end
local dungeonID
if (type(nodes[uiMapId][coord].id) == "table") then
dungeonID = nodes[uiMapId][coord].id[1]
else
dungeonID = nodes[uiMapId][coord].id
end

if (not dungeonID) then return end

local name, _, _, _, _, _, _, link = EJ_GetInstanceInfo(dungeonID)
if not link then return end
local difficulty = string.match(link, 'journal:.-:.-:(.-)|h')
if (not dungeonID or not difficulty) then return end
EncounterJournal_OpenJournal(difficulty, dungeonID)
_G.EncounterJournal:SetScript("OnShow", BBBEncounterJournal_OnShow)
end
end


nodes[1978] = { } -- Dragon Isles
nodes[2095] = { } -- Ruby Life Pools
nodes[2022] = { } -- The Waking Shores

nodes[1978][52884168] = {
id = 1202,
type = "Dungeon",
} -- Ruby Life Pools

This works perfectly, the journal opens with the associated dungeon, done, but how do I get this to work?

nodes[2095][42789333] = {
uiMapId = 2022,
name = L["Exit"],
type = "Exit",
showInZone = true,
} -- Ruby Life Pools

It shows the symbol on the Ruby Life Pools map, but when you click on it it doesn't open The Walking Shores map

Fizzlemizz 12-16-23 10:21 AM

You need to put code inside code tags (# button abvove the edit box for plain or the blue "Lua" button next to it for pretty).

In your function:
Lua Code:
  1. if (type(nodes[uiMapId][coord].id) == "table") then
  2.     dungeonID = nodes[uiMapId][coord].id[1]
  3. else
  4.     dungeonID = nodes[uiMapId][coord].id
  5. end
  6.  
  7. if (not dungeonID) then return end
if the the table does not contain an id entry (dungeonID is empty) it just exits doing nothing.
Lua Code:
  1. nodes[2095][42789333] = {
  2.     uiMapId = 2022,
  3.     name = L["Exit"],
  4.     type = "Exit",
  5.     showInZone = true,
  6. } -- Ruby Life Pools
does not contain an id entry (it does have a uiMapId entry).


All times are GMT -6. The time now is 12:40 AM.

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