The general for expects 3 arguments: the value to be called, some value that is passed to it again, and the key in which the iteration should begin.
Stock lua does not call pairs for the first value passed to if if it is not callable, although some derivatives do.
So you should use ipairs(itemlist) , pairs(itemlist) , next, itemlist or whatever you want (the last two have the same behavior and are what most derivatives do).
An iterator unpacks a sequence of values ...
function awesome_next(t, k) local k, v = next(t, k) if not v then return end return k, table.unpack(v) end for k, a, b, c, d in awesome_next, t do end
source share