from retail
This commit is contained in:
+12
-12
@@ -1911,25 +1911,25 @@ local function createScanFunc(trigger)
|
||||
if use_tooltip and trigger.tooltip_operator and trigger.tooltip then
|
||||
if trigger.tooltip_operator == "==" then
|
||||
local ret2 = [[
|
||||
if not matchData.tooltip or not matchData.tooltip == %q then
|
||||
if not matchData.tooltip or not matchData.tooltip == %s then
|
||||
return false
|
||||
end
|
||||
]]
|
||||
ret = ret .. ret2:format(trigger.tooltip)
|
||||
ret = ret .. ret2:format(Private.QuotedString(trigger.tooltip))
|
||||
elseif trigger.tooltip_operator == "find('%s')" then
|
||||
local ret2 = [[
|
||||
if not matchData.tooltip or not matchData.tooltip:find(%q) then
|
||||
if not matchData.tooltip or not matchData.tooltip:find(%s, 1, true) then
|
||||
return false
|
||||
end
|
||||
]]
|
||||
ret = ret .. ret2:format(trigger.tooltip)
|
||||
ret = ret .. ret2:format(Private.QuotedString(trigger.tooltip))
|
||||
elseif trigger.tooltip_operator == "match('%s')" then
|
||||
local ret2 = [[
|
||||
if not matchData.tooltip or not matchData.tooltip:match(%q) then
|
||||
if not matchData.tooltip or not matchData.tooltip:match(%s) then
|
||||
return false
|
||||
end
|
||||
]]
|
||||
ret = ret .. ret2:format(trigger.tooltip)
|
||||
ret = ret .. ret2:format(Private.QuotedString(trigger.tooltip))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1946,25 +1946,25 @@ local function createScanFunc(trigger)
|
||||
if trigger.useNamePattern and trigger.namePattern_operator and trigger.namePattern_name then
|
||||
if trigger.namePattern_operator == "==" then
|
||||
local ret2 = [[
|
||||
if not matchData.name == %q then
|
||||
if not matchData.name == %s then
|
||||
return false
|
||||
end
|
||||
]]
|
||||
ret = ret .. ret2:format(trigger.namePattern_name)
|
||||
ret = ret .. ret2:format(Private.QuotedString(trigger.namePattern_name))
|
||||
elseif trigger.namePattern_operator == "find('%s')" then
|
||||
local ret2 = [[
|
||||
if not matchData.name:find(%q) then
|
||||
if not matchData.name:find(%s, 1, true) then
|
||||
return false
|
||||
end
|
||||
]]
|
||||
ret = ret .. ret2:format(trigger.namePattern_name)
|
||||
ret = ret .. ret2:format(Private.QuotedString(trigger.namePattern_name))
|
||||
elseif trigger.namePattern_operator == "match('%s')" then
|
||||
local ret2 = [[
|
||||
if not matchData.name:match(%q) then
|
||||
if not matchData.name:match(%s) then
|
||||
return false
|
||||
end
|
||||
]]
|
||||
ret = ret .. ret2:format(trigger.namePattern_name)
|
||||
ret = ret .. ret2:format(Private.QuotedString(trigger.namePattern_name))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -44,14 +44,14 @@ local function formatValueForAssignment(vType, value, pathToCustomFunction, path
|
||||
return value and tostring(value) or "0";
|
||||
elseif (vType == "list") then
|
||||
if type(value) == "string" then
|
||||
return string.format("%q", value)
|
||||
return string.format("%s", Private.QuotedString(value))
|
||||
elseif type(value) == "number" then
|
||||
return tostring(value)
|
||||
end
|
||||
return "nil"
|
||||
elseif (vType == "icon") then
|
||||
if type(value) == "string" then
|
||||
return string.format("%q", value)
|
||||
return string.format("%s", Private.QuotedString(value))
|
||||
elseif type(value) == "number" then
|
||||
return tostring(value)
|
||||
end
|
||||
@@ -63,18 +63,19 @@ local function formatValueForAssignment(vType, value, pathToCustomFunction, path
|
||||
return "{1, 1, 1, 1}";
|
||||
elseif(vType == "chat") then
|
||||
if (value and type(value) == "table") then
|
||||
local serialized = string.format("{message_type = %q, message = %q, message_dest = %q, message_channel = %q, message_custom = %s, message_formaters = %s}",
|
||||
tostring(value.message_type), tostring(value.message or ""),
|
||||
tostring(value.message_dest), tostring(value.message_channel),
|
||||
local serialized = string.format("{message_type = %s, message = %s, message_dest = %s, message_channel = %s, message_custom = %s, message_formaters = %s}",
|
||||
Private.QuotedString(tostring(value.message_type)), Private.QuotedString(tostring(value.message or "")),
|
||||
Private.QuotedString(tostring(value.message_dest)), Private.QuotedString(tostring(value.message_channel)),
|
||||
pathToCustomFunction,
|
||||
pathToFormatters)
|
||||
return serialized
|
||||
end
|
||||
elseif(vType == "sound") then
|
||||
if (value and type(value) == "table") then
|
||||
return string.format("{ sound = %q, sound_channel = %q, sound_path = %q, sound_kit_id = %q, sound_type = %q, %s}",
|
||||
tostring(value.sound or ""), tostring(value.sound_channel or ""), tostring(value.sound_path or ""),
|
||||
tostring(value.sound_kit_id or ""), tostring(value.sound_type or ""),
|
||||
return string.format("{ sound = %s, sound_channel = %s, sound_path = %s, sound_kit_id = %s, sound_type = %s, %s}",
|
||||
Private.QuotedString(tostring(value.sound or "")), Private.QuotedString(tostring(value.sound_channel or "")),
|
||||
Private.QuotedString(tostring(value.sound_path or "")), Private.QuotedString(tostring(value.sound_kit_id or "")),
|
||||
Private.QuotedString(tostring(value.sound_type or "")),
|
||||
value.sound_repeat and "sound_repeat = " .. tostring(value.sound_repeat) or "nil");
|
||||
end
|
||||
elseif(vType == "customcode") then
|
||||
|
||||
@@ -137,12 +137,13 @@ end
|
||||
function TestForLongString(trigger, arg)
|
||||
local name = arg.name;
|
||||
local test;
|
||||
local needle = trigger[name]
|
||||
if(trigger[name.."_operator"] == "==") then
|
||||
test = ("(%s == %q)"):format(name, trigger[name])
|
||||
test = ("(%s == %s)"):format(name, Private.QuotedString(needle))
|
||||
elseif(trigger[name.."_operator"] == "find('%s')") then
|
||||
test = "(" .. name .. " and " .. name .. string.format(":find(%q)", trigger[name]) .. ")"
|
||||
test = "(" .. name .. " and " .. name .. string.format(":find(%s, 1, true)", Private.QuotedString(needle)) .. ")"
|
||||
elseif(trigger[name.."_operator"] == "match('%s')") then
|
||||
test = "(" .. name .. " and " .. name .. string.format(":match(%q)", trigger[name]) .. ")"
|
||||
test = "(" .. name .. " and " .. name .. string.format(":match(%s)", Private.QuotedString(needle)) .. ")"
|
||||
end
|
||||
return test;
|
||||
end
|
||||
|
||||
+22
-2
@@ -563,9 +563,9 @@ local function ConstructFunction(prototype, trigger, skipOptional)
|
||||
end
|
||||
elseif(arg.type == "tristatestring") then
|
||||
if(trigger["use_"..name] == false) then
|
||||
test = "("..name.. "~=".. (number or string.format("%q", trigger[name] or "")) .. ")"
|
||||
test = "("..name.. "~=".. (number or string.format("%s", Private.QuotedString(trigger[name] or ""))) .. ")"
|
||||
elseif(trigger["use_"..name]) then
|
||||
test = "("..name.. "==".. (number or string.format("%q", trigger[name] or "")) .. ")"
|
||||
test = "("..name.. "==".. (number or string.format("%s", Private.QuotedString(trigger[name] or ""))) .. ")"
|
||||
end
|
||||
elseif(arg.type == "multiselect") then
|
||||
if(trigger["use_"..name] == false) then -- multi selection
|
||||
@@ -4659,3 +4659,23 @@ function Private.IconSources(data)
|
||||
end
|
||||
return values
|
||||
end
|
||||
|
||||
-- This should be used instead of string.format("...%q...", input)
|
||||
-- e.g. string.format("...%s...", Private.QuotedString(input))
|
||||
-- If the string is passed to loadstring.
|
||||
-- It escapes --, which loadstring would otherwise interpret as comment starts
|
||||
function Private.QuotedString(input)
|
||||
local str = string.format("%q", input)
|
||||
return (str:gsub("%-%-", "-\\-"))
|
||||
end
|
||||
|
||||
-- Helper function to make the templates not care, how the generic triggers
|
||||
-- are categorized
|
||||
function WeakAuras.GetTriggerCategoryFor(triggerType)
|
||||
local prototype = Private.event_prototypes[triggerType]
|
||||
return prototype and prototype.type
|
||||
end
|
||||
|
||||
function WeakAuras.UnitStagger(unit)
|
||||
return UnitStagger(unit) or 0
|
||||
end
|
||||
Reference in New Issue
Block a user