Just posting this for the sake of readability, since you might want to consider some other practices when it comes to doing repeated bits of code. You already have a function that creates the buttons, which is great, but using a data table and a single click function with changing arguments instead of hardcoding every button will look a lot cleaner and it will be much easier to add more buttons to it.
This code is untested, but you should get the general idea.
Lua Code:
local buttons = {
{
icon = "achievement_pvp_a_h",
pos = "Warspear Keep"
},
{
icon = "achievement_garrison_tier02_horde",
pos = "Emberfall Tower",
target = true
},
{
icon = "achievement_garrison_tier01_horde",
pos = "Volrath's Advance",
target = true
},
{
icon = "achievement_doublejeopardy",
pos = "The Crossroads",
target = true
},
{
icon = "achievement_garrison_tier01_alliance",
pos = "Tremblade's Vanguard",
target = true
},
{
icon = "achievement_garrison_tier02_alliance",
pos = "Archmage Overwatch",
target = true
},
{
icon = "achievement_pvp_h_a",
pos = "Stormshield Stronghold",
target = true
},
{
msg = "AoA - EVENT:STADIUM RACING - Block the entrance!",
icon = "Ability_rogue_sprint",
pos = "Amphitheater of Annihilation(AoA)",
target = true
},
{
msg = "BR - EVENT:OGRE FIRES - Block the stairs!",
icon = "spell_fire_fire",
pos = "Brute's Rise(BR)",
target = true
},
{
msg = "Ring of Conquest GO RoC",
icon = "achievement_boss_furyfurnace",
pos = "Ring of Conquest(RoC)",
target = true
},
{
msg = "Ashran Excavation - EVENT:APEXIS MARKS - Secure the center!",
icon = "Trade_archaeology_apexisstatue",
pos = "Ashran Excavation(Mines)",
target = true
},
{
msg = "Seat of Kor'lok - Kor'lok - Kill the ogre!",
icon = "achievement_reputation_ogre",
pos = "Seat of Kor'lok",
target = true
},
{
msg = "Molten Quarry - EVENT:Empowered Ore - Block the entrance!",
icon = "Spell_lifegivingspeed",
pos = "Molten Quarry(MQ)",
target = true
},
{
msg = "Ashmaul Burial Grounds - EVENT:RISEN SPIRITS - Clear the center and block the entrance!",
icon = "Achievement_halloween_ghost_01",
pos = "Ashmaul Burial Grounds(ABG)",
target = true
},
}
local mid = #buttons / 2
local function OnClick(self)
SendChatMessage(self.msg.." ", "SAY")
DoEmote("follow", self.target and UnitName("target"))
end
ACFrame.Buttons = {}
for i, info in pairs(buttons) do
local button = CreateButton(AshranCommander, "$parentButton"..i, "Interface\\Icons\\"..info.icon, nil, info.pos)
button:SetScript("OnClick", OnClick)
button.msg = info.msg or info.pos
button.target = info.target
if i == 1 then
button:SetPoint("TOPRIGHT", ACFrame, "CENTER", 13, -13)
elseif i > mid then
button:SetPoint("RIGHT", ACFrame.Buttons[i-mid], "LEFT", 0, 0)
else
button:SetPoint("TOP", ACFrame.Buttons[i-1], "BOTTOM", 0, -1)
end
tinsert(ACFrame.Buttons, button)
end