add map area id (zoneId) support for load auras

This commit is contained in:
Bunny67
2020-12-27 22:24:13 +03:00
parent e0672fe539
commit e7c46c8d5f
2 changed files with 34 additions and 2 deletions
+31
View File
@@ -545,6 +545,26 @@ function WeakAuras.CheckTalentByIndex(index)
return rank and rank > 0;
end
function WeakAuras.CheckNumericIds(loadids, currentId)
if (not loadids or not currentId) then
return false;
end
local searchFrom = 0;
local startI, endI = string.find(loadids, currentId, searchFrom);
while (startI) do
searchFrom = endI + 1; -- start next search from end
if (startI == 1 or tonumber(string.sub(loadids, startI - 1, startI - 1)) == nil) then
-- Either right at start, or character before is not a number
if (endI == string.len(loadids) or tonumber(string.sub(loadids, endI + 1, endI + 1)) == nil) then
return true;
end
end
startI, endI = string.find(loadids, currentId, searchFrom);
end
return false;
end
function WeakAuras.CheckString(ids, currentId)
if (not ids or not currentId) then
return false;
@@ -858,6 +878,17 @@ Private.load_prototype = {
events = {"ZONE_CHANGED", "ZONE_CHANGED_INDOORS", "ZONE_CHANGED_NEW_AREA", "VEHICLE_UPDATE"},
desc = L["Supports multiple entries, separated by commas"]
},
{
name = "zoneId",
display = L["Zone ID(s)"],
type = "string",
init = "arg",
test = "WeakAuras.CheckNumericIds(%q, zoneId)",
events = {"ZONE_CHANGED", "ZONE_CHANGED_INDOORS", "ZONE_CHANGED_NEW_AREA", "VEHICLE_UPDATE"},
desc = function()
return ("\n|cffffd200%s|r%s: %d\n\n%s"):format(L["Current Zone\n"], GetRealZoneText(), GetCurrentMapAreaID(), L["Supports multiple entries, separated by commas"])
end
},
{
name = "size",
display = L["Instance Type"],
+3 -2
View File
@@ -1179,6 +1179,7 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...)
local player, realm, zone = UnitName("player"), GetRealmName(), GetRealZoneText();
local faction = UnitFactionGroup("player")
local zoneId = GetCurrentMapAreaID()
local _, class = UnitClass("player");
@@ -1199,8 +1200,8 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...)
if (data and not data.controlledChildren) then
local loadFunc = loadFuncs[id];
local loadOpt = loadFuncsForOptions[id];
shouldBeLoaded = loadFunc and loadFunc("ScanForLoads_Auras", inCombat, vehicle, vehicleUi, group, player, realm, class, faction, playerLevel, zone, size, difficulty);
couldBeLoaded = loadOpt and loadOpt("ScanForLoads_Auras", inCombat, vehicle, vehicleUi, group, player, realm, class, faction, playerLevel, zone, size, difficulty);
shouldBeLoaded = loadFunc and loadFunc("ScanForLoads_Auras", inCombat, vehicle, vehicleUi, group, player, realm, class, faction, playerLevel, zone, zoneId, size, difficulty);
couldBeLoaded = loadOpt and loadOpt("ScanForLoads_Auras", inCombat, vehicle, vehicleUi, group, player, realm, class, faction, playerLevel, zone, zoneId, size, difficulty);
if(shouldBeLoaded and not loaded[id]) then
changed = changed + 1;