Thread Tools Display Modes
10-15-23, 02:29 AM   #1
Ssesmar
A Deviate Faerie Dragon
Join Date: Oct 2023
Posts: 15
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

Last edited by Ssesmar : 10-15-23 at 02:34 AM.
  Reply With Quote
12-16-23, 10:21 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
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).
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-16-23 at 10:38 AM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » function to switch from one map to another?

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