local Util = {} function Util.indexOf(haystack, needle) for b,blade in pairs(haystack) do if blade == needle then return b end end end function Util.getNext(stack, item, d) local w = Util.indexOf(stack, item) if not w then return nil end local i = (((w-1) + d) % #stack) + 1 return stack[i] end return Util