from retail

This commit is contained in:
NoM0Re
2025-01-24 18:12:49 +01:00
parent 4ef5381aaa
commit 3fcb60f399
5 changed files with 185 additions and 179 deletions
+80 -79
View File
@@ -2154,124 +2154,124 @@ local function createScanFunc(trigger)
return nil
end
local preamble = ""
local preamble = {""}
local ret = [[
local ret = {[=[
return function(time, matchData)
]]
]=]}
if use_total then
local ret2 = [[
local ret2 = [=[
if not(matchData.duration %s %s) then
return false
end
]]
ret = ret .. ret2:format(trigger.totalOperator or ">=", tonumber(trigger.total) or 0)
]=]
table.insert(ret, ret2:format(trigger.totalOperator or ">=", tonumber(trigger.total) or 0))
end
if useStacks then
local ret2 = [[
local ret2 = [=[
if not(matchData.stacks %s %s) then
return false
end
]]
ret = ret .. ret2:format(trigger.stacksOperator or ">=", tonumber(trigger.stacks) or 0)
]=]
table.insert(ret, ret2:format(trigger.stacksOperator or ">=", tonumber(trigger.stacks) or 0))
end
if use_stealable then
ret = ret .. [[
table.insert(ret, [=[
if not matchData.isStealable then
return false
end
]]
]=])
elseif use_stealable == false then
ret = ret .. [[
table.insert(ret, [=[
if matchData.isStealable then
return false
end
]]
]=])
end
if use_debuffClass then
local ret2 = [[
local ret2 = [=[
local tDebuffClass = %s;
if not tDebuffClass[matchData.debuffClass] then
return false
end
]]
ret = ret .. ret2:format(trigger.debuffClass and type(trigger.debuffClass) == "table" and Private.SerializeTable(trigger.debuffClass) or "{}")
]=]
table.insert(ret, ret2:format(trigger.debuffClass and type(trigger.debuffClass) == "table" and Private.SerializeTable(trigger.debuffClass) or "{}"))
end
if trigger.ownOnly then
ret = ret .. [[
table.insert(ret, [=[
if matchData.unitCaster ~= 'player' and matchData.unitCaster ~= 'pet' and matchData.unitCaster ~= 'vehicle' then
return false
end
]]
]=])
elseif trigger.ownOnly == false then
ret = ret .. [[
table.insert(ret, [=[
if matchData.unitCaster == 'player' or matchData.unitCaster == 'pet' or matchData.unitCaster == 'vehicle' then
return false
end
]]
]=])
end
if use_tooltip and trigger.tooltip_operator and trigger.tooltip then
if trigger.tooltip_operator == "==" then
local ret2 = [[
local ret2 = [=[
if not matchData.tooltip or matchData.tooltip ~= %s then
return false
end
]]
ret = ret .. ret2:format(Private.QuotedString(trigger.tooltip))
]=]
table.insert(ret, ret2:format(Private.QuotedString(trigger.tooltip)))
elseif trigger.tooltip_operator == "find('%s')" then
local ret2 = [[
local ret2 = [=[
if not matchData.tooltip or not matchData.tooltip:find(%s, 1, true) then
return false
end
]]
ret = ret .. ret2:format(Private.QuotedString(trigger.tooltip))
]=]
table.insert(ret, ret2:format(Private.QuotedString(trigger.tooltip)))
elseif trigger.tooltip_operator == "match('%s')" then
local ret2 = [[
local ret2 = [=[
if not matchData.tooltip or not matchData.tooltip:match(%s) then
return false
end
]]
ret = ret .. ret2:format(Private.QuotedString(trigger.tooltip))
]=]
table.insert(ret, ret2:format(Private.QuotedString(trigger.tooltip)))
end
end
if use_tooltipValue and trigger.tooltipValueNumber and trigger.tooltipValue_operator and trigger.tooltipValue then
local property = "tooltip" .. tonumber(trigger.tooltipValueNumber)
local ret2 = [[
local ret2 = [=[
if not matchData.%s or not (matchData.%s %s %s) then
return false
end
]]
]=]
ret = ret .. ret2:format(property, property, trigger.tooltipValue_operator, trigger.tooltipValue)
end
if trigger.useNamePattern and trigger.namePattern_operator and trigger.namePattern_name then
if trigger.namePattern_operator == "==" then
local ret2 = [[
local ret2 = [=[
if not matchData.name == %s then
return false
end
]]
ret = ret .. ret2:format(Private.QuotedString(trigger.namePattern_name))
]=]
table.insert(ret, ret2:format(Private.QuotedString(trigger.namePattern_name)))
elseif trigger.namePattern_operator == "find('%s')" then
local ret2 = [[
local ret2 = [=[
if not matchData.name:find(%s, 1, true) then
return false
end
]]
ret = ret .. ret2:format(Private.QuotedString(trigger.namePattern_name))
]=]
table.insert(ret, ret2:format(Private.QuotedString(trigger.namePattern_name)))
elseif trigger.namePattern_operator == "match('%s')" then
local ret2 = [[
local ret2 = [=[
if not matchData.name:match(%s) then
return false
end
]]
ret = ret .. ret2:format(Private.QuotedString(trigger.namePattern_name))
]=]
table.insert(ret, ret2:format(Private.QuotedString(trigger.namePattern_name)))
end
end
@@ -2283,40 +2283,40 @@ local function createScanFunc(trigger)
tinsert(names, name)
end
preamble = preamble .. "local ignoreNames = {\n"
table.insert(preamble, "local ignoreNames = {\n")
for index, name in ipairs(names) do
preamble = preamble .. string.format(" [%q] = true,\n", name)
table.insert(preamble, string.format(" [%q] = true,\n", name))
end
preamble = preamble .. "}\n"
ret = ret .. [[
table.insert(preamble, "}\n")
table.insert(ret, [=[
if ignoreNames[matchData.name] then
return false
end
]]
]=])
end
if use_ignore_spellId then
preamble = preamble .. "local ignoreSpellId = {\n"
table.insert(preamble, "local ignoreSpellId = {\n")
for index, spellId in ipairs(trigger.ignoreAuraSpellids) do
local spell = WeakAuras.SafeToNumber(spellId)
if spell then
preamble = preamble .. string.format(" [%s] = true,\n", spell)
table.insert(preamble, string.format(" [%s] = true,\n", spell))
end
end
preamble = preamble .. "}\n"
ret = ret .. [[
table.insert(preamble, "}\n")
table.insert(ret, [=[
if ignoreSpellId[matchData.spellId] then
return false
end
]]
]=])
end
ret = ret .. [[
table.insert(ret, [=[
return true
end
]]
]=])
local func, err = loadstring(preamble .. ret)
local func, err = loadstring(table.concat(preamble) .. table.concat(ret))
if func then
return func()
@@ -2623,50 +2623,51 @@ end
function BuffTrigger.GetAdditionalProperties(data, triggernum)
local trigger = data.triggers[triggernum].trigger
local ret = "|cFFFFCC00%".. triggernum .. ".spellId|r - " .. L["Spell ID"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".debuffClass|r - " .. L["Debuff Class"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".unitCaster|r - " .. L["Caster Unit"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".casterName|r - " .. L["Caster Name"] .. "\n"
local ret = {"|cFFFFCC00%".. triggernum .. ".spellId|r - " .. L["Spell ID"] .. "\n"}
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".debuffClass|r - " .. L["Debuff Class"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".debuffClassIcon|r - " .. L["Debuff Class Icon"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".unitCaster|r - " .. L["Caster Unit"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".casterName|r - " .. L["Caster Name"] .. "\n")
if trigger.unit ~= "multi" then
ret = ret .. "|cFFFFCC00%".. triggernum .. ".unit|r - " .. L["Unit"] .. "\n"
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".unit|r - " .. L["Unit"] .. "\n")
end
ret = ret .. "|cFFFFCC00%".. triggernum .. ".unitName|r - " .. L["Unit Name"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".matchCount|r - " .. L["Match Count"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".matchCountPerUnit|r - " .. L["Match Count per Unit"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".unitCount|r - " .. L["Units Affected"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".totalStacks|r - " .. L["Total stacks over all matches"] .. "\n"
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".unitName|r - " .. L["Unit Name"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".matchCount|r - " .. L["Match Count"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".matchCountPerUnit|r - " .. L["Match Count per Unit"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".unitCount|r - " .. L["Units Affected"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".totalStacks|r - " .. L["Total stacks over all matches"] .. "\n")
if trigger.unit ~= "multi" then
ret = ret .. "|cFFFFCC00%".. triggernum .. ".maxUnitCount|r - " .. L["Total Units"] .. "\n"
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".maxUnitCount|r - " .. L["Total Units"] .. "\n")
end
if not IsSingleMissing(trigger) and trigger.unit ~= "multi" and trigger.fetchTooltip then
ret = ret .. "|cFFFFCC00%".. triggernum .. ".tooltip|r - " .. L["Tooltip"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".tooltip1|r - " .. L["First Value of Tooltip Text"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".tooltip2|r - " .. L["Second Value of Tooltip Text"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".tooltip3|r - " .. L["Third Value of Tooltip Text"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".tooltip4|r - " .. L["Fourth Value of Tooltip Text"] .. "\n"
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".tooltip|r - " .. L["Tooltip"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".tooltip1|r - " .. L["First Value of Tooltip Text"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".tooltip2|r - " .. L["Second Value of Tooltip Text"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".tooltip3|r - " .. L["Third Value of Tooltip Text"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".tooltip4|r - " .. L["Fourth Value of Tooltip Text"] .. "\n")
end
if trigger.unit ~= "multi" then
ret = ret .. "|cFFFFCC00%".. triggernum .. ".stackGainTime|r - " .. L["Since Stack Gain"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".stackLostTime|r - " .. L["Since Stack Lost"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".initialTime|r - " .. L["Since Apply"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".refreshTime|r - " .. L["Since Apply/Refresh"] .. "\n"
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".stackGainTime|r - " .. L["Since Stack Gain"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".stackLostTime|r - " .. L["Since Stack Lost"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".initialTime|r - " .. L["Since Apply"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".refreshTime|r - " .. L["Since Apply/Refresh"] .. "\n")
end
if trigger.unit ~= "multi" and trigger.fetchRaidMark then
ret = ret .. "|cFFFFCC00%".. triggernum .. ".raidMark|r - " .. L["Raid Mark"] .. "\n"
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".raidMark|r - " .. L["Raid Mark"] .. "\n")
end
if (trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party") and trigger.useAffected then
ret = ret .. "|cFFFFCC00%".. triggernum .. ".affected|r - " .. L["Names of affected Players"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".unaffected|r - " .. L["Names of unaffected Players"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".affectedUnits|r - " .. L["Units of affected Players in a table format"] .. "\n"
ret = ret .. "|cFFFFCC00%".. triggernum .. ".unaffectedUnits|r - " .. L["Units of unaffected Players in a table format"] .. "\n"
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".affected|r - " .. L["Names of affected Players"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".unaffected|r - " .. L["Names of unaffected Players"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".affectedUnits|r - " .. L["Units of affected Players in a table format"] .. "\n")
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".unaffectedUnits|r - " .. L["Units of unaffected Players in a table format"] .. "\n")
end
return ret
return table.concat(ret)
end
function BuffTrigger.GetProgressSources(data, triggernum, values)
+96 -81
View File
@@ -165,7 +165,12 @@ local function formatValueForCall(type, property)
return "nil";
end
function Private.ExecEnv.CancelConditionCheck(uid, cloneId)
if conditionChecksTimers.recheckHandle[uid] and conditionChecksTimers.recheckHandle[uid][cloneId] then
timer:CancelTimer(conditionChecksTimers.recheckHandle[uid][cloneId])
conditionChecksTimers.recheckHandle[uid][cloneId] = nil
end
end
function Private.ExecEnv.ScheduleConditionCheck(time, uid, cloneId)
conditionChecksTimers.recheckTime[uid] = conditionChecksTimers.recheckTime[uid] or {}
@@ -299,10 +304,11 @@ local function CreateTestForCondition(data, input, allConditionsTemplate, usedSt
if pausedProperty and remainingProperty then
local pausedString = "state[" .. trigger .. "]" .. string.format("[%q]", pausedProperty)
local remainingString = "(state[" .. trigger .. "]" .. string.format("[%q]", remainingProperty) .. " or 0)"
remainingTime = "((" .. pausedString .. " and " .. remainingString .. ") or " .. remainingTime .. ")"
end
if (op == "==") then
check = stateCheck .. stateVariableCheck .. "abs((" .. remainingTime .. "-" .. value .. ")" .. " < 0.05"
check = stateCheck .. stateVariableCheck .. "abs((" .. remainingTime .. "-" .. value .. ")" .. ") < 0.05"
else
check = stateCheck .. stateVariableCheck .. remainingTime .. op .. value
end
@@ -379,7 +385,15 @@ local function CreateTestForCondition(data, input, allConditionsTemplate, usedSt
-- If adding a new condition type, don't forget to adjust the validator in the options code
if (cType == "timer" and value) then
recheckCode = " nextTime = state[" .. trigger .. "] and state[" .. trigger .. "]" .. string.format("[%q]", variable) .. " and (state[" .. trigger .. "]" .. string.format("[%q]", variable) .. " - " .. value .. ")\n";
local variableString = "state[" .. trigger .. "]" .. string.format("[%q]", variable)
local andNotPaused = pausedProperty
and "and not " .. "state[" .. trigger .. "]" .. string.format("[%q]", pausedProperty)
or ""
recheckCode = " nextTime = state[" .. trigger .. "] " .. andNotPaused
.. " and " .. variableString
.. " and " .. "(" .. variableString .. " - " .. value .. ")\n"
recheckCode = recheckCode .. " if (nextTime and (not recheckTime or nextTime < recheckTime) and nextTime >= now) then\n"
recheckCode = recheckCode .. " recheckTime = nextTime\n";
recheckCode = recheckCode .. " end\n"
@@ -401,19 +415,19 @@ local function CreateCheckCondition(data, ret, condition, conditionNumber, allCo
check = "false"
end
if condition.linked and conditionNumber > 1 then
ret = ret .. " elseif (" .. check .. ") then\n";
table.insert(ret, " elseif (" .. check .. ") then\n")
else
ret = ret .. " if (" .. check .. ") then\n";
table.insert(ret, " if (" .. check .. ") then\n")
end
ret = ret .. " newActiveConditions[" .. conditionNumber .. "] = true;\n";
table.insert(ret, " newActiveConditions[" .. conditionNumber .. "] = true;\n")
if not nextIsLinked then
ret = ret .. " end\n";
table.insert(ret, " end\n")
end
if (check) then
ret = ret .. "\n";
table.insert(ret, "\n")
end
return ret, recheckCode;
return recheckCode;
end
local function ParseProperty(property)
@@ -447,27 +461,27 @@ end
local function CreateDeactivateCondition(ret, condition, conditionNumber, data, properties, usedProperties, debug)
if (condition.changes) then
ret = ret .. " if (activatedConditions[".. conditionNumber .. "] and not newActiveConditions[" .. conditionNumber .. "]) then\n"
if (debug) then ret = ret .. " print('Deactivating condition " .. conditionNumber .. "' )\n"; end
table.insert(ret, " if (activatedConditions[".. conditionNumber .. "] and not newActiveConditions[" .. conditionNumber .. "]) then\n")
if (debug) then table.insert(ret, " print('Deactivating condition " .. conditionNumber .. "' )\n") end
for changeNum, change in ipairs(condition.changes) do
if (change.property) then
local propertyData = properties and properties[change.property]
if (propertyData and propertyData.type and propertyData.setter) then
usedProperties[change.property] = true;
ret = ret .. " propertyChanges['" .. change.property .. "'] = "
table.insert(ret, " propertyChanges['" .. change.property .. "'] = "
.. formatValueForAssignment(propertyData.type, GetBaseProperty(data, change.property),
nil, nil, data)
.. "\n";
.. "\n")
if (debug) then
ret = ret .. " print('- " .. change.property .. " "
table.insert(ret, " print('- " .. change.property .. " "
.. formatValueForAssignment(propertyData.type, GetBaseProperty(data, change.property),
nil, nil, data)
.. "')\n";
.. "')\n")
end
end
end
end
ret = ret .. " end\n"
table.insert(ret, " end\n")
end
return ret;
@@ -475,20 +489,20 @@ end
local function CreateActivateCondition(ret, id, condition, conditionNumber, data, properties, debug)
if (condition.changes) then
ret = ret .. " if (newActiveConditions[" .. conditionNumber .. "]) then\n"
ret = ret .. " if (not activatedConditions[".. conditionNumber .. "]) then\n"
if (debug) then ret = ret .. " print('Activating condition " .. conditionNumber .. "' )\n"; end
table.insert(ret, " if (newActiveConditions[" .. conditionNumber .. "]) then\n")
table.insert(ret, " if (not activatedConditions[".. conditionNumber .. "]) then\n")
if (debug) then table.insert(ret, " print('Activating condition " .. conditionNumber .. "' )\n") end
-- non active => active
for changeNum, change in ipairs(condition.changes) do
if (change.property) then
local propertyData = properties and properties[change.property]
if (propertyData and propertyData.type) then
if (propertyData.setter) then
ret = ret .. " propertyChanges['" .. change.property .. "'] = "
.. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "\n"
table.insert(ret, " propertyChanges['" .. change.property .. "'] = "
.. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "\n")
if (debug) then
ret = ret .. " print('- " .. change.property .. " "
.. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "')\n"
table.insert(ret, " print('- " .. change.property .. " "
.. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "')\n")
end
elseif (propertyData.action) then
local pathToCustomFunction = "nil";
@@ -505,39 +519,39 @@ local function CreateActivateCondition(ret, id, condition, conditionNumber, data
and Private.ExecEnv.conditionTextFormatters[id][conditionNumber].changes[changeNum] then
pathToFormatter = string.format("Private.ExecEnv.conditionTextFormatters[%q][%s].changes[%s]", id, conditionNumber, changeNum);
end
ret = ret .. " region:" .. propertyData.action .. "("
table.insert(ret, " region:" .. propertyData.action .. "("
.. formatValueForAssignment(propertyData.type, change.value,
pathToCustomFunction, pathToFormatter, data)
.. ")" .. "\n";
.. ")" .. "\n")
if (debug) then
ret = ret .. " print('# " .. propertyData.action .. "("
table.insert(ret, " print('# " .. propertyData.action .. "("
.. formatValueForAssignment(propertyData.type, change.value,
pathToCustomFunction, pathToFormatter, data)
.. "')\n";
.. "')\n")
end
end
end
end
end
ret = ret .. " else\n"
table.insert(ret, " else\n")
-- active => active, only override properties
for changeNum, change in ipairs(condition.changes) do
if (change.property) then
local propertyData = properties and properties[change.property]
if (propertyData and propertyData.type and propertyData.setter) then
ret = ret .. " if(propertyChanges['" .. change.property .. "'] ~= nil) then\n"
ret = ret .. " propertyChanges['" .. change.property .. "'] = "
.. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "\n"
if (debug) then ret = ret .. " print('- " .. change.property .. " "
.. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "')\n" end
ret = ret .. " end\n"
table.insert(ret, " if(propertyChanges['" .. change.property .. "'] ~= nil) then\n")
table.insert(ret, " propertyChanges['" .. change.property .. "'] = "
.. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "\n")
if (debug) then table.insert(ret, " print('- " .. change.property .. " "
.. formatValueForAssignment(propertyData.type, change.value, nil, nil, data) .. "')\n") end
table.insert(ret, " end\n")
end
end
end
ret = ret .. " end\n"
ret = ret .. " end\n"
ret = ret .. "\n";
ret = ret .. " activatedConditions[".. conditionNumber .. "] = newActiveConditions[" .. conditionNumber .. "]\n";
table.insert(ret, " end\n")
table.insert(ret, " end\n")
table.insert(ret, "\n")
table.insert(ret, " activatedConditions[".. conditionNumber .. "] = newActiveConditions[" .. conditionNumber .. "]\n")
end
return ret;
@@ -673,80 +687,81 @@ function Private.GetGlobalConditions()
end
local function ConstructConditionFunction(data)
local debug = false;
local debug = false
if (not data.conditions or #data.conditions == 0) then
return nil;
return nil
end
local usedProperties = {};
local usedProperties = {}
local allConditionsTemplate = Private.GetTriggerConditions(data);
allConditionsTemplate[-1] = Private.GetGlobalConditions();
local allConditionsTemplate = Private.GetTriggerConditions(data)
allConditionsTemplate[-1] = Private.GetGlobalConditions()
local ret = "";
ret = ret .. "local newActiveConditions = {};\n"
ret = ret .. "local propertyChanges = {};\n"
ret = ret .. "local nextTime;\n"
ret = ret .. string.format("local uid = %q\n", data.uid)
ret = ret .. "return function(region, hideRegion)\n";
if (debug) then ret = ret .. " print('check conditions for:', region.id, region.cloneId)\n"; end
ret = ret .. " local id = region.id\n";
ret = ret .. " local cloneId = region.cloneId or ''\n";
ret = ret .. " local state = region.states\n"
ret = ret .. " local activatedConditions = WeakAuras.GetActiveConditions(id, cloneId)\n";
ret = ret .. " wipe(newActiveConditions)\n";
ret = ret .. " local recheckTime;\n"
ret = ret .. " local now = GetTime();\n"
local ret = {""}
table.insert(ret, "local newActiveConditions = {};\n")
table.insert(ret, "local propertyChanges = {};\n")
table.insert(ret, "local nextTime;\n")
table.insert(ret, string.format("local uid = %q\n", data.uid))
table.insert(ret, "return function(region, hideRegion)\n")
if (debug) then table.insert(ret, " print('check conditions for:', region.id, region.cloneId)\n") end
table.insert(ret, " local id = region.id\n")
table.insert(ret, " local cloneId = region.cloneId or ''\n")
table.insert(ret, " local state = region.states\n")
table.insert(ret, " local activatedConditions = WeakAuras.GetActiveConditions(id, cloneId)\n")
table.insert(ret, " wipe(newActiveConditions)\n")
table.insert(ret, " local recheckTime;\n")
table.insert(ret, " local now = GetTime();\n")
-- First Loop gather which conditions are active
ret = ret .. " if (not hideRegion) then\n"
local recheckCode = ""
table.insert(ret, " if (not hideRegion) then\n")
local recheckCode = {}
if (data.conditions) then
Private.ExecEnv.conditionHelpers[data.uid] = nil
for conditionNumber, condition in ipairs(data.conditions) do
local nextIsLinked = data.conditions[conditionNumber + 1] and data.conditions[conditionNumber + 1].linked
local additionalRecheckCode
ret, additionalRecheckCode = CreateCheckCondition(data, ret, condition, conditionNumber, allConditionsTemplate, nextIsLinked, debug)
local additionalRecheckCode = CreateCheckCondition(data, ret, condition, conditionNumber, allConditionsTemplate, nextIsLinked, debug)
if additionalRecheckCode then
recheckCode = recheckCode .. "\n" .. additionalRecheckCode
table.insert(recheckCode, additionalRecheckCode)
end
end
end
ret = ret .. recheckCode
ret = ret .. " end\n";
table.insert(ret, table.concat(recheckCode))
table.insert(ret, " end\n")
ret = ret .. " if (recheckTime) then\n"
ret = ret .. " Private.ExecEnv.ScheduleConditionCheck(recheckTime, uid, cloneId);\n"
ret = ret .. " end\n"
table.insert(ret, " if (recheckTime) then\n")
table.insert(ret, " Private.ExecEnv.ScheduleConditionCheck(recheckTime, uid, cloneId);\n")
table.insert(ret, " else\n")
table.insert(ret, " Private.ExecEnv.CancelConditionCheck(uid, cloneId)")
table.insert(ret, " end\n")
local properties = Private.GetProperties(data);
local properties = Private.GetProperties(data)
-- Now build a property + change list
-- Second Loop deals with conditions that are no longer active
ret = ret .. " wipe(propertyChanges)\n"
table.insert(ret, " wipe(propertyChanges)\n")
if (data.conditions) then
for conditionNumber, condition in ipairs(data.conditions) do
ret = CreateDeactivateCondition(ret, condition, conditionNumber, data, properties, usedProperties, debug)
CreateDeactivateCondition(ret, condition, conditionNumber, data, properties, usedProperties, debug)
end
end
ret = ret .. "\n";
table.insert(ret, "\n")
-- Third Loop deals with conditions that are newly active
if (data.conditions) then
for conditionNumber, condition in ipairs(data.conditions) do
ret = CreateActivateCondition(ret, data.id, condition, conditionNumber, data, properties, debug)
CreateActivateCondition(ret, data.id, condition, conditionNumber, data, properties, debug)
end
end
-- Last apply changes to region
for property, _ in pairs(usedProperties) do
ret = ret .. " if(propertyChanges['" .. property .. "'] ~= nil) then\n"
local arg1 = "";
table.insert(ret, " if(propertyChanges['" .. property .. "'] ~= nil) then\n")
local arg1 = ""
if (properties[property].arg1) then
if (type(properties[property].arg1) == "number") then
arg1 = tostring(properties[property].arg1) .. ", ";
arg1 = tostring(properties[property].arg1) .. ", "
else
arg1 = "'" .. properties[property].arg1 .. "', ";
arg1 = "'" .. properties[property].arg1 .. "', "
end
end
@@ -756,13 +771,13 @@ local function ConstructConditionFunction(data)
base = "region.subRegions[" .. subIndex .. "]:"
end
ret = ret .. " " .. base .. properties[property].setter .. "(" .. arg1 .. formatValueForCall(properties[property].type, property) .. ")\n";
if (debug) then ret = ret .. " print('Calling " .. properties[property].setter .. " with', " .. arg1 .. formatValueForCall(properties[property].type, property) .. ")\n"; end
ret = ret .. " end\n";
table.insert(ret, " " .. base .. properties[property].setter .. "(" .. arg1 .. formatValueForCall(properties[property].type, property) .. ")\n")
if (debug) then table.insert(ret, " print('Calling " .. properties[property].setter .. " with', " .. arg1 .. formatValueForCall(properties[property].type, property) .. ")\n") end
table.insert(ret, " end\n")
end
ret = ret .. "end\n";
table.insert(ret, "end\n")
return ret;
return table.concat(ret)
end
local function CancelTimers(uid)
+5 -12
View File
@@ -3839,11 +3839,9 @@ end
function GenericTrigger.GetAdditionalProperties(data, triggernum)
local trigger = data.triggers[triggernum].trigger
local ret = "";
local ret = {""};
local prototype = GenericTrigger.GetPrototype(trigger)
if prototype then
local found = false;
local additional = ""
for _, v in pairs(prototype.args) do
local enable = true
if(type(v.enable) == "function") then
@@ -3853,16 +3851,11 @@ function GenericTrigger.GetAdditionalProperties(data, triggernum)
end
if (enable and v.store and v.name and v.display and v.conditionType ~= "bool") then
found = true;
additional = additional .. "|cFFFFCC00%".. triggernum .. "." .. v.name .. "|r - " .. v.display .. "\n";
table.insert(ret, "|cFFFFCC00%".. triggernum .. "." .. v.name .. "|r - " .. v.display .. "\n")
end
end
if prototype.countEvents then
found = true;
additional = additional .. "|cFFFFCC00%".. triggernum .. ".count|r - " .. L["Count"] .. "\n";
end
if (found) then
ret = ret .. additional;
table.insert(ret, "|cFFFFCC00%".. triggernum .. ".count|r - " .. L["Count"] .. "\n")
end
else
if (trigger.custom_type == "stateupdate") then
@@ -3871,7 +3864,7 @@ function GenericTrigger.GetAdditionalProperties(data, triggernum)
for var, varData in pairs(variables) do
if (type(varData) == "table") then
if varData.display then
ret = ret .. "|cFFFFCC00%".. triggernum .. "." .. var .. "|r - " .. varData.display .. "\n"
table.insert(ret, "|cFFFFCC00%".. triggernum .. "." .. var .. "|r - " .. varData.display .. "\n")
end
end
end
@@ -3879,7 +3872,7 @@ function GenericTrigger.GetAdditionalProperties(data, triggernum)
end
end
return ret;
return table.concat(ret);
end
function GenericTrigger.GetProgressSources(data, triggernum, values)
+4
View File
@@ -80,6 +80,10 @@ function WeakAuras.IsLibsOK()
return libsAreOk
end
if not libsAreOk then
WeakAuras.prettyPrint("WeakAuras is missing necessary libraries. Please reinstall a proper package.")
end
if versionString ~= versionStringFromToc and versionStringFromToc ~= "Dev" then
WeakAuras.prettyPrint("You need to restart your game client to complete the WeakAuras update!")
end
-7
View File
@@ -3619,19 +3619,12 @@ Private.event_prototypes = {
local itemName = type(trigger.itemName) == "number" and trigger.itemName or string.format("%q", trigger.itemName or "0")
local ret = [=[
local itemname = %s;
print("Debug: itemname =", itemname)
local name = GetItemInfo(itemname or 0) or "Invalid"
print("Debug: name =", name)
local icon = GetItemIcon(itemname or 0)
print("Debug: icon =", icon)
local showgcd = %s
print("Debug: showgcd =", showgcd)
local startTime, duration, enabled, gcdCooldown = WeakAuras.GetItemCooldown(itemname, showgcd);
print("Debug: startTime =", startTime, "duration =", duration, "enabled =", enabled, "gcdCooldown =", gcdCooldown)
local expirationTime = startTime + duration
print("Debug: expirationTime =", expirationTime)
local genericShowOn = %s
print("Debug: genericShowOn =", genericShowOn)
state.itemname = itemname;
]=];
if(trigger.use_remaining and trigger.genericShowOn ~= "showOnReady") then