Módulo:PetTools: mudanças entre as edições
Ir para navegação
Ir para pesquisar
Sem resumo de edição |
Sem resumo de edição |
||
| (2 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
| Linha 2: | Linha 2: | ||
function p.HPRender(frame) | function p.HPRender(frame) | ||
local icon = " | local icon = "PetHPIcon.png" | ||
local iconDisabled = " | local iconDisabled = "PetHPIconDisabled.png" | ||
local hpGain = frame.args.hpGain or 0 | local hpGain = tonumber(frame.args.hpGain) or 0 | ||
local hpBonus = frame.args.bonusPerHundredLevels or 0 | local hpBonus = tonumber(frame.args.bonusPerHundredLevels) or 0 | ||
local totalGain = hpGain + hpBonus/100 | local totalGain = hpGain + hpBonus/100 | ||
local colored = math.max(1, math.min(5, math.floor(totalGain) | local stepNeeded = 23/5 | ||
local colored = math.max(1, math.min(5, math.floor(totalGain / stepNeeded))) | |||
local total = 5 | local total = 5 | ||
local result = {} | local result = {} | ||
| Linha 14: | Linha 15: | ||
for i = 1, total do | for i = 1, total do | ||
if i <= colored then | if i <= colored then | ||
table.insert(result, string.format("[[File:%s|link=]]", icon)) | table.insert(result, string.format("[[File:%s|20x20px|link=]]", icon)) | ||
else | else | ||
table.insert(result, string.format("[[File:%s|link=]]", iconDisabled)) | table.insert(result, string.format("[[File:%s|20x20px|link=]]", iconDisabled)) | ||
end | end | ||
end | end | ||
return table.concat(result,"") | return table.concat(result, "") | ||
end | end | ||
function p.MPRender(frame) | function p.MPRender(frame) | ||
local icon = frame.args. | local icon = "PetMPIcon.png" | ||
local | local iconDisabled = "PetMPIconDisabled.png" | ||
local | local totalGain = tonumber(frame.args.mpGain) or 0 | ||
return " | |||
local colored = math.max(1, math.min(5, math.floor(totalGain / 5))) | |||
local total = 5 | |||
local result = {} | |||
for i = 1, total do | |||
if i <= colored then | |||
table.insert(result, string.format("[[File:%s|20x20px|link=]]", icon)) | |||
else | |||
table.insert(result, string.format("[[File:%s|20x20px|link=]]", iconDisabled)) | |||
end | |||
end | |||
return table.concat(result, "") | |||
end | end | ||
return p | return p | ||
Edição atual tal como às 10h22min de 19 de agosto de 2025
A documentação para este módulo pode ser criada em Módulo:PetTools/doc
local p = {}
function p.HPRender(frame)
local icon = "PetHPIcon.png"
local iconDisabled = "PetHPIconDisabled.png"
local hpGain = tonumber(frame.args.hpGain) or 0
local hpBonus = tonumber(frame.args.bonusPerHundredLevels) or 0
local totalGain = hpGain + hpBonus/100
local stepNeeded = 23/5
local colored = math.max(1, math.min(5, math.floor(totalGain / stepNeeded)))
local total = 5
local result = {}
for i = 1, total do
if i <= colored then
table.insert(result, string.format("[[File:%s|20x20px|link=]]", icon))
else
table.insert(result, string.format("[[File:%s|20x20px|link=]]", iconDisabled))
end
end
return table.concat(result, "")
end
function p.MPRender(frame)
local icon = "PetMPIcon.png"
local iconDisabled = "PetMPIconDisabled.png"
local totalGain = tonumber(frame.args.mpGain) or 0
local colored = math.max(1, math.min(5, math.floor(totalGain / 5)))
local total = 5
local result = {}
for i = 1, total do
if i <= colored then
table.insert(result, string.format("[[File:%s|20x20px|link=]]", icon))
else
table.insert(result, string.format("[[File:%s|20x20px|link=]]", iconDisabled))
end
end
return table.concat(result, "")
end
return p