I like to cycle arrays backward and forward and I do it so often, I wrote a function that does it, so I save a little bit of time.
p, li { white-space: pre-wrap; }
function cycletable(w,orig)
if w:lower() == "next" then
table.insert(orig,orig[1])
table.remove(orig,1)
elseif w:lower() == "previous" then
table.insert(orig, 1, orig[#orig])
table.remove(orig, #orig)
end
end
Usage is:
cycletable("next", tablename) to cycle forward
and
cycletable("previous", tablename) to cycle backward.
Because it's doing something funky to my formatting above,
here is a pastebin.
Comments
targets = {"mosr", "cesarina", "shecks"} and it'll cycle forward and backwards through the list.
I use it for things like ship weapon handling, targets, offence-type (1v1, gank, raid). I prefer to use this kind of thing rather than an alias because I can assign it to a macro and just cycle.