View Single Post
06-13-22, 05:40 AM   #8
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
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:
  1. function own:getnext(tbl, item)
  2.     if tbl[#tbl] == item then
  3.         return tbl[1]
  4.     else
  5.         local found
  6.         for i = 1, #tbl do
  7.             if found then
  8.                 return tbl[i]
  9.             end
  10.             found = tbl[i] == item
  11.         end
  12.     end
  13. end
  Reply With Quote