View Single Post
10-25-18, 10:23 PM   #13
Urtgard
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 25
Lua Code:
  1. local f = CreateFrame("Button","TabParty2",nil,"SecureActionButtonTemplate")
  2. f:SetAttribute("type","target")
  3. SecureHandlerWrapScript(f,"OnClick",f,[[
  4.     local unit
  5.     for i=1,5,1 do
  6.         TabPartyIndex = ((TabPartyIndex or 1) - 2)%5 + 1
  7.         if TabPartyIndex == 5 then
  8.             unit = "player"
  9.         else
  10.             unit = "party"..TabPartyIndex
  11.         end
  12.         if UnitExists(unit) then
  13.             self:SetAttribute("unit",unit)
  14.             break
  15.         end
  16.     end
  17. ]])

i=5,1,-1 or i=1,5,1 doesn't matter in this case.

The real counting is:
Lua Code:
  1. TabPartyIndex = (TabPartyIndex or 0)%5 + 1

Last edited by Urtgard : 10-25-18 at 10:36 PM.
  Reply With Quote