WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Gello's Cycle Arena Modification (https://www.wowinterface.com/forums/showthread.php?t=59515)

r00tdownx 02-22-23 07:08 PM

Gello's Cycle Arena Modification
 
Hi guys I would like to mod gello's arena cycles. Could someone help me out?

1. I would like the functionality so the leftbutton will not cycle past party1 and the rightbutton will not cycle past party5. Right now it loops from party1 to party5.

2. If no party member is selected I would like leftbutton to select party1 and rightbutton to select the bottom party member either 2/3/5 or 40 depending on party size.

Thanks!

-- binding definitions
BINDING_HEADER_CYCLEARENA = "Cycle Arena"
_G["BINDING_NAME_CLICK CycleArenaTarget:LeftButton"] = "Cycle Arena Target Forward"
_G["BINDING_NAME_CLICK CycleArenaTarget:RightButton"] = "Cycle Arena Target Backward"
_G["BINDING_NAME_CLICK CycleArenaFocus:LeftButton"] = "Cycle Arena Focus Forward"
_G["BINDING_NAME_CLICK CycleArenaFocus:RightButton"] = "Cycle Arena Focus Backward"
_G["BINDING_NAME_CLICK CyclePartyTarget:LeftButton"] = "Cycle Party Target Forward"
_G["BINDING_NAME_CLICK CyclePartyTarget:RightButton"] = "Cycle Party Target Backward"
_G["BINDING_NAME_CLICK CyclePartyFocus:LeftButton"] = "Cycle Party Focus Forward"
_G["BINDING_NAME_CLICK CyclePartyFocus:RightButton"] = "Cycle Party Focus Backward"
_G["BINDING_NAME_CLICK CycleRaidTarget:LeftButton"] = "Cycle Raid Target Forward"
_G["BINDING_NAME_CLICK CycleRaidTarget:RightButton"] = "Cycle Raid Target Backward"
_G["BINDING_NAME_CLICK CycleRaidFocus:LeftButton"] = "Cycle Raid Focus Forward"
_G["BINDING_NAME_CLICK CycleRaidFocus:RightButton"] = "Cycle Raid Focus Backward"

-- create a secure button for each binding
for k,name in pairs({"CycleArenaTarget","CycleArenaFocus","CyclePartyTarget","CyclePartyFocus","CycleRaidTarget","CycleRaidFocus"}) do
local button = CreateFrame("Button",name,nil,"SecureActionButtonTemplate")
-- set up persistent attributes to describe the button's behavior
button:SetAttribute("maxUnits",k<=4 and 5 or 40)
button:SetAttribute("unitType",k<=2 and "arena" or k<=4 and "party" or "raid")
button:SetAttribute("unitIndex",0)
local targetType = k%2==0 and "focus" or "target"
button:SetAttribute("type1",targetType)
button:SetAttribute("type2",targetType)
button:RegisterForClicks(GetCVarBool("ActionButtonUseKeyDown") and "AnyDown" or "AnyUp")
-- create a pre-click snippet to increment/decrement unit
SecureHandlerWrapScript(button,"OnClick",button,[[
local maxUnits = self:GetAttribute("maxUnits") -- 5 for arena, 5 for party, 40 for raid
local unitType = self:GetAttribute("unitType")
local index = self:GetAttribute("unitIndex") -- number 0-X of last seen unit
local direction = button=="RightButton" and -1 or 1
for i=1,maxUnits do
index = (index+direction)%5
local unit = unitType..index+1
if unit=="party5" then
unit = "player" -- for party targeting, 5th unit is player
end
if UnitExists(unit) then
self:SetAttribute("unitIndex",index)
self:SetAttribute("unit",unit)
return
end
end
self:SetAttribute("unit",nil) -- if no unit, don't target
]])
end

SDPhantom 02-23-23 03:24 PM

The simplest way I'd go at it is to remove the modulo operation from this line. It'll be safe to remove the parenthesis too.
Code:

index = (index+direction)%5
It might also help to add a check to break the loop if index is out of bounds.
Code:

index = index+direction
if index<0 or index>=maxUnits then break end

Note index appears to be zero-based and has +1 added when generating the UnitID.


All times are GMT -6. The time now is 03:04 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI