Fix PUI npcId that never worked correctly

This commit is contained in:
NoM0Re
2024-08-25 14:04:21 +02:00
parent 6cfb24673c
commit 79f6935837
2 changed files with 89 additions and 6 deletions
+55 -6
View File
@@ -1417,8 +1417,21 @@ Private.event_prototypes = {
display = L["Npc ID"],
type = "string",
store = true,
init = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '')",
conditionType = "string",
test = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '') == %q",
preamble = "local npcIdChecker = WeakAuras.ParseStringCheck(%q)",
test = "npcIdChecker:Check(npcId)",
conditionPreamble = function(input)
return WeakAuras.ParseStringCheck(input)
end,
conditionTest = function(state, needle, op, preamble)
return preamble:Check(state.npcId)
end,
operator_types = "none",
desc = L["Supports multiple entries, separated by commas"],
enable = function(trigger)
return not trigger.use_inverse
end,
},
{
name = "attackable",
@@ -1702,8 +1715,21 @@ Private.event_prototypes = {
display = L["Npc ID"],
type = "string",
store = true,
init = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '')",
conditionType = "string",
test = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '') == %q",
preamble = "local npcIdChecker = WeakAuras.ParseStringCheck(%q)",
test = "npcIdChecker:Check(npcId)",
conditionPreamble = function(input)
return WeakAuras.ParseStringCheck(input)
end,
conditionTest = function(state, needle, op, preamble)
return preamble:Check(state.npcId)
end,
operator_types = "none",
desc = L["Supports multiple entries, separated by commas"],
enable = function(trigger)
return not trigger.use_inverse
end,
},
{
name = "class",
@@ -1986,8 +2012,21 @@ Private.event_prototypes = {
display = L["Npc ID"],
type = "string",
store = true,
init = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '')",
conditionType = "string",
test = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '') == %q",
preamble = "local npcIdChecker = WeakAuras.ParseStringCheck(%q)",
test = "npcIdChecker:Check(npcId)",
conditionPreamble = function(input)
return WeakAuras.ParseStringCheck(input)
end,
conditionTest = function(state, needle, op, preamble)
return preamble:Check(state.npcId)
end,
operator_types = "none",
desc = L["Supports multiple entries, separated by commas"],
enable = function(trigger)
return not trigger.use_inverse
end,
},
{
name = "class",
@@ -5505,11 +5544,21 @@ Private.event_prototypes = {
display = L["Npc ID"],
type = "string",
store = true,
init = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '')",
conditionType = "string",
test = "tostring(tonumber(string.sub(UnitGUID(unit) or '', 8, 12), 16) or '') == %q",
preamble = "local npcIdChecker = WeakAuras.ParseStringCheck(%q)",
test = "npcIdChecker:Check(npcId)",
conditionPreamble = function(input)
return WeakAuras.ParseStringCheck(input)
end,
conditionTest = function(state, needle, op, preamble)
return preamble:Check(state.npcId)
end,
operator_types = "none",
desc = L["Supports multiple entries, separated by commas"],
enable = function(trigger)
return not trigger.use_inverse
end
return not trigger.use_inverse
end,
},
{
name = "class",
+34
View File
@@ -4786,6 +4786,40 @@ function WeakAuras.ParseZoneCheck(input)
return matcher
end
function WeakAuras.ParseStringCheck(input)
if not input then return end
local matcher = {
zones = {},
Check = function(self, zone)
return self.zones[zone]
end,
Add = function(self, z)
self.zones[z] = true
end
}
local start = 1
local escaped = false
local partial = ""
for i = 1, #input do
local c = input:sub(i, i)
if escaped then
escaped = false
elseif c == '\\' then
partial = partial .. input:sub(start, i - 1)
start = i + 1
escaped = true
elseif c == "," then
matcher:Add(partial .. input:sub(start, i - 1):trim())
start = i + 1
partial = ""
end
end
matcher:Add(partial .. input:sub(start, #input):trim())
return matcher
end
function WeakAuras.IsAuraLoaded(id)
return Private.loaded[id]
end