lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Ugh, haven't used Lua in a year or so, then discovered I could script
the interface of my game with it (World of Warcraft).  Now I have what
feels like a newbie question:

How can I tell the number of elements in table T? I'm not using it as
a list, so table.getn always returns 0. Do I need to write something
like this?

function numelements (t)
  local n = 0
  for k,v in t do
    n = n + 1
  return n

That seems very kludgey.