Open main menu
Home
Random
Log in
Settings
About AddOn Studio
Disclaimers
AddOn Studio
Search
Editing
Engine:UI Macro
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- Create a frame to hold mage portal icons local portalFrame = CreateFrame("Frame", "MagePortalFrame", UIParent) portalFrame:SetSize(200, 300) portalFrame:SetPoint("RIGHT") portalFrame:Hide() -- Hide the frame by default -- Function to create a portal button local button = CreateFrame("Button", ADDON_NAME .. "CraftButton", frame, "UIPanelButtonTemplate") button:SetText("Craft") button:SetSize(100, 25) button:SetPoint("BOTTOM", frame, "BOTTOM", 0, 10) button:SetScript("OnClick", function() if selectedItem then local itemName = selectedItem:GetText() if itemName then SendChatMessage("/cast " .. portalName, "SAY") end end end) -- Create portal buttons local function CreatePortalButtons() local faction = UnitFactionGroup("player") local portals = { {portalName= "Portal: Orgrimmar", texturePath = "Interface\\Icons\\Spell_Arcane_PortalOrgrimmar", faction = "Horde"}, {portalName = "Portal: Stormwind", texturePath = "Interface\\Icons\\Spell_Arcane_PortalStormwind", faction = "Alliance"}, {portalName = "Portal: Ironforge", texturePath = "Interface\\Icons\\Spell_Arcane_PortalIronForge", faction = "Alliance"}, {portalName = "Portal: Darnassus", texturePath = "Interface\\Icons\\Spell_Arcane_PortalDarnassus", faction = "Alliance"}, {portalName = "Portal: Thunder Bluff", texturePath = "Interface\\Icons\\Spell_Arcane_PortalThunderBluff", faction = "Horde"}, {portalName = "Portal: Undercity", texturePath = "Interface\\Icons\\Spell_Arcane_PortalUnderCity", faction = "Horde"}, {portalName = "Portal: Silvermoon", texturePath = "Interface\\Icons\\Spell_Arcane_PortalSilvermoon", faction = "Horde"}, {portalName = "Portal: Exodar", texturePath = "Interface\\Icons\\Spell_Arcane_PortalExodar", faction = "Alliance"}, {portalName = "Portal: Shattrath", texturePath = "Interface\\Icons\\Spell_Arcane_PortalShattrath", faction = "Neutral"}, {portalName = "Portal: Dalaran - Northrend", texturePath = "Interface\\Icons\\Spell_Arcane_PortalDalaran", faction = "Neutral"} } local yOffset = -10 for _, portal in ipairs(portals) do if portal.faction == faction or portal.faction == "Neutral" then local button = CreatePortalButton(portal.portalName, portal.texturePath) button:SetPoint("TOP", 0, yOffset) yOffset = yOffset - 50 end end end -- Toggle frame visibility function local function ToggleFrameVisibility() if portalFrame:IsVisible() then portalFrame:Hide() else portalFrame:Show() end end -- Create a button to toggle frame visibility on minimap local toggleButton = CreateFrame("Button", nil, Minimap) toggleButton:SetSize(20, 20) toggleButton:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 0, 0) toggleButton:SetNormalTexture("Interface\\Icons\\Ability_Hunter_BeastTaming") toggleButton:SetScript("OnClick", ToggleFrameVisibility) -- Initialize addon local addon = CreateFrame("Frame") addon:RegisterEvent("ADDON_LOADED") addon:SetScript("OnEvent", function(self, event, addonName) if addonName == "MagePortal" then CreatePortalButtons() end end)
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)