That's smart, I tend to get a little complicated before I get the code slimmed down.
However, that won't return the first indexed item if you feed it the last one. I adjusted it:
Lua Code:
function own:getnext(tbl, item)
if tbl[#tbl] == item then
return tbl[1]
else
local found
for i = 1, #tbl do
if found then
return tbl[i]
end
found = tbl[i] == item
end
end
end