Getting an error that I don't know how to resolve:
lua Code:
-- SET CITIES --
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
-- SET DESTINATION --
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()
-- other code
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", setLoc(i)) -- line 149
end
end
Code:
Message: Interface\AddOns\MageTaxi\magetaxi.lua:91: attempt to index field '?' (a nil value)
Time: 02/09/10 21:08:49
Count: 1
Stack: Interface\AddOns\MageTaxi\magetaxi.lua:91: in function <Interface\AddOns\MageTaxi\magetaxi.lua:89>
Interface\AddOns\MageTaxi\magetaxi.lua:149: in function `MageTaxi_createGUI'
[string "MageTaxi_createGUI()"]:1: in main chunk
[C]: in function `RunScript'
Locals: i = 1
(for index) = 2
(for limit) = 7
(for step) = 1
num = 2
(*temporary) = nil
(*temporary) = nil
(*temporary) = "2"
(*temporary) = "attempt to index field '?' (a nil value)"
As far as the checkbuttons, it's only creating one and stopping (leading to the error, figured that part out). I'm looking for
WHY it's not building all the buttons.