Module:Constants: Difference between revisions

_getModifierText: Implement support for value ranges
m (Add missing modifier skill)
(_getModifierText: Implement support for value ranges)
Line 78: Line 78:
["RangedEvasion"] = { text = "{V}% Ranged Evasion", skills = {'Combat'} },
["RangedEvasion"] = { text = "{V}% Ranged Evasion", skills = {'Combat'} },
["ChanceDoubleHarvest"] = { text = "{V}% chance for double harvest", skills = {'Farming'} },
["ChanceDoubleHarvest"] = { text = "{V}% chance for double harvest", skills = {'Farming'} },
["golbinRaidStartingWeapon"] = { text = "Start the Golbin Raid with an {IV}" },
["golbinRaidStartingWeapon"] = { text = "Start the Golbin Raid with an {VITEM}", unsigned = true },
["AttackRolls"] = { text = "+Lucky Hit Chance (Roll twice, take the better result)", skills = {'Combat'} },
["AttackRolls"] = { text = "+Lucky Hit Chance (Roll twice, take the better result)", skills = {'Combat'} },
["AmmoPreservation"] = { text = "{V}% Ammo Preservation", skills = {'Ranged'} },
["AmmoPreservation"] = { text = "{V}% Ammo Preservation", skills = {'Ranged'} },
Line 155: Line 155:
["summoningSynergy_9_11"] = {text = "The Chef in Thieving now deals no damage to you.", skills = {'Thieving'}},
["summoningSynergy_9_11"] = {text = "The Chef in Thieving now deals no damage to you.", skills = {'Thieving'}},
["summoningSynergy_9_16"] = {text = "Crafting Recipes that require Dragonhide now use {V} quantity to create. Recipe cost cannot go below 1.", skills = {'Crafting'}, inverseSign = true},
["summoningSynergy_9_16"] = {text = "Crafting Recipes that require Dragonhide now use {V} quantity to create. Recipe cost cannot go below 1.", skills = {'Crafting'}, inverseSign = true},
["summoningSynergy_9_17"] = {text = "-{VMS}s Skill Interval for Cooking & Smithing.", skills = {'Cooking', 'Smithing'}},
["summoningSynergy_9_17"] = {text = "{VMS}s Skill Interval for Cooking & Smithing.", inverseSign = true, skills = {'Cooking', 'Smithing'}},
["summoningSynergy_9_18"] = {text = "Generous Cook Potions now provide {V}% charges. This bonus is applied when a new potion is activated.", skills = {'Cooking'}},
["summoningSynergy_9_18"] = {text = "Generous Cook Potions now provide {V}% charges. This bonus is applied when a new potion is activated.", skills = {'Cooking'}},
["summoningSynergy_10_11"] = {text = "Successfully pickpocketting the Miner in Thieving will now grant {V} Rune Essence.", skills = {'Thieving'}},
["summoningSynergy_10_11"] = {text = "Successfully pickpocketting the Miner in Thieving will now grant {V} Rune Essence.", skills = {'Thieving'}},
Line 207: Line 207:
["debuffImmunity"] = { text = "Immune to debuffs", skills = {'Combat'} },
["debuffImmunity"] = { text = "Immune to debuffs", skills = {'Combat'} },
["Decay"] = { text = "Take {V}% of Max HP as damage on a succesful attack", isIncreaseNegative = true, skills = {'Combat'} },
["Decay"] = { text = "Take {V}% of Max HP as damage on a succesful attack", isIncreaseNegative = true, skills = {'Combat'} },
["doubleItemsSkill"] = { text = "x{VMUL} Items received from {SV0}" },
["doubleItemsSkill"] = { text = "x{VMUL} Items received from {SV0}", unsigned = true },
["doubleOresMining"] = { text = "x{VMUL} Ores received from Mining", skills = {'Mining'} },
["doubleOresMining"] = { text = "x{VMUL} Ores received from Mining", unsigned = true, skills = {'Mining'} },
["DragonBreathDamage"] = { text = "{V}% damage taken from dragonbreath", isIncreaseNegative = true, skills = {'Combat'} },
["DragonBreathDamage"] = { text = "{V}% damage taken from dragonbreath", isIncreaseNegative = true, skills = {'Combat'} },
["FiremakingCoalChance"] = { text = "{V}% chance to receive coal when burning logs in Firemaking", skills = {'Firemaking'} },
["FiremakingCoalChance"] = { text = "{V}% chance to receive coal when burning logs in Firemaking", skills = {'Firemaking'} },
Line 256: Line 256:
["RedemptionThreshold"] = { text = "{V}% redemption threshold", skills = {'Combat'} },
["RedemptionThreshold"] = { text = "{V}% redemption threshold", skills = {'Combat'} },
["RolledReflectDamage"] = { text = "{S}0-{VX} Reflect Damage", unsigned = true, skills = {'Combat'} },
["RolledReflectDamage"] = { text = "{S}0-{VX} Reflect Damage", unsigned = true, skills = {'Combat'} },
["RuneProvision"] = { text = "Rune providing items provide {VMUL}x as many runes", skills = {'Combat'} },
["RuneProvision"] = { text = "Rune providing items provide {VMUL}x as many runes", unsigned = true, skills = {'Combat'} },
["SecondaryFoodBurnChance"] = { text = "{V}% Secondary Chance to burn food when Cooking", isIncreaseNegative = true, skills = {'Cooking'} },
["SecondaryFoodBurnChance"] = { text = "{V}% Secondary Chance to burn food when Cooking", isIncreaseNegative = true, skills = {'Cooking'} },
["sleepImmunity"] = { text = "Immune to Sleep", skills = {'Combat'} },
["sleepImmunity"] = { text = "Immune to Sleep", skills = {'Combat'} },
Line 486: Line 486:
return 'ERROR: Invalid modifier type for ' .. modifier .. '[[Category:Pages with script errors]]'
return 'ERROR: Invalid modifier type for ' .. modifier .. '[[Category:Pages with script errors]]'
end
end
local formatModValue = function(value, rule)
local ruleFunctions = {
['V'] = function(val) return val end,
['VD'] = function(val) return val / 10 end,
['VMS'] = function(val) return val / 1000 end,
['VX'] = function(val) return val * 10 end,
['VX100'] = function(val) return val * 100 end,
['V%+100'] = function(val) return val + 100 end,
['VMUL'] = function(val) return 2^val end,
['VITEM'] = function(val)
local item = ItemData.Items[tonumber(val) + 1]
if item ~= nil then
return item.name
end
end
}
local ruleFunc = ruleFunctions[rule] or ruleFunctions['V']
if type(value) == 'table' then
-- If table is a pair of values then format both & add a separator
return ruleFunc(value[1]) .. '-' .. ruleFunc(value[2])
else
return ruleFunc(value)
end
end


local result = modText
local result = modText
Line 497: Line 523:
end
end
return table.concat(resultArray, '<br/>')
return table.concat(resultArray, '<br/>')
else
elseif Shared.contains(modText, '{SV0}') then
-- If the value is a table and the mod text contains {SV0}, then
-- the value is a {skillID, val} pair, otherwise it is a range of
-- values {minVal, maxVal}
if value[1] ~= nil then
if value[1] ~= nil then
local skillName = p.getSkillName(value[1])
local skillName = p.getSkillName(value[1])
Line 507: Line 536:
end
end
end
end
-- Re-check the type of value, as it may have been modified above even if it was originally a table
if type(value) ~= 'table' then
local valSign = (valueUnsigned and '' or sign)
local valSign = (valueUnsigned and '' or sign)
result = string.gsub(result, '{(V[^}]*)}', function(rule) return valSign .. formatModValue(value, rule) end)
if string.find(result, '{IV}', 1, true) ~= nil and tonumber(value) ~= nil then
result = string.gsub(result, '{S}', sign)
local item = ItemData.Items[tonumber(value) + 1]
if item ~= nil then
result = string.gsub(result, '{IV}', item.name)
end
end
result = string.gsub(result, '{V}', valSign..value)
result = string.gsub(result, '{VD}', valSign..(value / 10))
result = string.gsub(result, '{VMS}', valSign..(value / 1000))
result = string.gsub(result, '{VX}', valSign..(value * 10))
result = string.gsub(result, '{VX100}', valSign..(value * 100))
result = string.gsub(result, '{V%+100}', valSign..(value + 100))
result = string.gsub(result, '{VMUL}', 2^value)
result = string.gsub(result, '{S}', sign)
end


if doColor then
if doColor then