17,105
edits
(getTemplateData: Fix actionID handling for Firemaking) |
(checkScopeDataMeetsCriteria: Support matching the absence of properties with string value 'nil') |
||
Line 177: | Line 177: | ||
local criteriaID = nil | local criteriaID = nil | ||
if keyMap.gameDataKey ~= nil then | if criteriaName == 'nil' then | ||
-- Special value used to check for the absence of a particular | |||
-- property by p.checkScopeDataMeetsCriteria() - passthrough | |||
criteriaID = criteriaName | |||
elseif keyMap.gameDataKey ~= nil then | |||
local criteriaData = GameData.getEntityByName(keyMap.gameDataKey, criteriaName) | local criteriaData = GameData.getEntityByName(keyMap.gameDataKey, criteriaName) | ||
if criteriaData ~= nil then | if criteriaData ~= nil then | ||
Line 200: | Line 204: | ||
-- This is used to check that a modifier provides its benefit to a given skill, or currency, | -- This is used to check that a modifier provides its benefit to a given skill, or currency, | ||
-- or so on. | -- or so on. | ||
-- dataCriteria accepts | -- Passing the string 'nil' as a value for any criteria indicates that a match should only | ||
-- | -- occur if the given property is absent from the given scope data | ||
-- negative ('neg') in order for the criteria to be met | -- dataCriteria accepts two additional properties that aren't usually found in scope data, being: | ||
-- - valueType: Indicates whether the value of the modifier should be positive ('pos') or | |||
-- negative ('neg') in order for the criteria to be met | |||
-- - modType: Similar to valueType, except determines whether the modifier is a positive ('pos') | |||
-- or negative ('neg') to the player, rather than simply determining the sign of | |||
-- the value as valueType does | |||
function p.checkScopeDataMeetsCriteria(modDefn, scopeData, scopeDefn, dataCriteria) | function p.checkScopeDataMeetsCriteria(modDefn, scopeData, scopeDefn, dataCriteria) | ||
for criteriaKey, criteriaValue in pairs(dataCriteria) do | for criteriaKey, criteriaValue in pairs(dataCriteria) do | ||
Line 243: | Line 252: | ||
and ( | and ( | ||
scopeData[criteriaKey] == nil | scopeData[criteriaKey] == nil | ||
or scopeData[criteriaKey] == 'nil' | |||
or scopeData[criteriaKey] ~= criteriaValue | or scopeData[criteriaKey] ~= criteriaValue | ||
) | ) |