Module:Health

local getArgs = require('Module:Arguments').getArgs local p = {}

function p.main(frame) local args = getArgs(frame) return p._main(args) end

function callTemplate(color, number) return mw.getCurrentFrame:expandTemplate{ title = 'Health/Segment', args = {color, number} } end

function handleType(health, colorName, retTable) while health + 0 > 0 do   if health + 0 >= 25 then temp = 25 else temp = health end health = health - temp table.insert( retTable, callTemplate(colorName, temp) ) end end

-- =p._main({health="60",armor="60"}) function p._main(args) local retTable = {} local armor = args['armor'] local shields = args['shields'] local tarmor = args['armor'] local tshields = args['tshields']

if args['health'] then handleType(args['health'], 'health', retTable) end if args['armor'] then handleType(args['armor'], 'armor', retTable) end if args['shields'] then handleType(args['shields'], 'shields', retTable) end if args['tarmor'] then handleType(args['tarmor'], 'temporary_armor', retTable) end if args['tshields'] then handleType(args['tshields'], 'temporary_shields', retTable) end

return ' ' .. table.concat( retTable, '' ) .. ' ' end

return p