Originally Posted by ChaosInc
Isn't just passing i doing the same thing, or am I not following this logic correctly?
Why would I want the name of a number?
... is still somewhat confusing to me. I understand that it's all arguments that are passed, but cb:SetScript("OnClick", setLoc) isn't passing anything, so how would I get the i value?
Still learning as I go along.
|
NOW I see what you want to do.... Here it comes:
Code:
function MageTaxi:SetFaction()
if UnitFactionGroup("player") == "Alliance" then
cityList = {
[1] = "Stormwind",
[2] = "Ironforge",
[3] = "Darnassus",
[4] = "Exodar",
[5] = "Theramore",
[6] = "Shattrath",
[7] = "Dalaran",
}
else
cityList = {
[1] = "Undercity",
[2] = "Orgrimmar",
[3] = "Thunder Bluff",
[4] = "Silvermoon",
[5] = "Stonard",
[6] = "Shattrath",
[7] = "Dalaran"
}
end;
dest = cityList[1]
end
local function setLoc(i)
for num= 1,#cityList do
_G["MageTaxi_City".. num]:SetChecked(false) -- line 91
end
dest = cityList[i]
_G["MageTaxi_City".. i]:SetChecked(true)
end
function MageTaxi_createGUI()
for i = 1,#cityList do
cb = CreateFrame("CHECKBUTTON", "MageTaxi_City"..i, f, "UIRadioButtonTemplate")
if i == 1 then
cb:SetPoint("TOPLEFT", f, "TOPLEFT", 40, -45)
else
cb:SetPoint("TOP", "MageTaxi_City".. (i-1), "BOTTOM", 0, -10)
end
cb:SetScript("OnClick", function() setLoc(i) end) -- line 149
end
end