View Single Post
02-09-10, 09:22 PM   #1
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Grr, I hate it when I miss stuff...

Getting an error that I don't know how to resolve:

lua Code:
  1. -- SET CITIES --
  2. function MageTaxi:SetFaction()
  3.     if UnitFactionGroup("player") == "Alliance" then
  4.         cityList = {
  5.             [1] = "Stormwind",
  6.             [2] = "Ironforge",
  7.             [3] = "Darnassus",
  8.             [4] = "Exodar",
  9.             [5] = "Theramore",
  10.             [6] = "Shattrath",
  11.             [7] = "Dalaran",
  12.         }
  13.     else
  14.         cityList = {
  15.             [1] = "Undercity",
  16.             [2] = "Orgrimmar",
  17.             [3] = "Thunder Bluff",
  18.             [4] = "Silvermoon",
  19.             [5] = "Stonard",
  20.             [6] = "Shattrath",
  21.             [7] = "Dalaran"
  22.         }
  23.     end;
  24.         dest = cityList[1]
  25. end
  26.  
  27. -- SET DESTINATION --
  28. local function setLoc(i)
  29.     for num= 1,#cityList do
  30.         _G["MageTaxi_City".. num]:SetChecked(false)  -- line 91
  31.     end
  32.     dest = cityList[i]
  33.     _G["MageTaxi_City".. i]:SetChecked(true)
  34. end
  35.  
  36. function MageTaxi_createGUI()
  37.     -- other code
  38.     for i = 1,#cityList do
  39.         cb = CreateFrame("CHECKBUTTON", "MageTaxi_City"..i, f, "UIRadioButtonTemplate")
  40.             if i == 1 then
  41.                 cb:SetPoint("TOPLEFT", f, "TOPLEFT", 40, -45)
  42.             else
  43.                 cb:SetPoint("TOP", "MageTaxi_City".. (i-1), "BOTTOM", 0, -10)
  44.             end
  45.             cb:SetScript("OnClick", setLoc(i)) -- line 149
  46.         end
  47. 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.

Last edited by Sythalin : 02-09-10 at 09:24 PM.
  Reply With Quote