Module:Param Parse: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
No edit summary
No edit summary
Line 448: Line 448:


-- Requirements
-- Requirements
function parse.requirements_func(value)
function parse.requirements_func(input_string)
local icon_map = {
local icon_map = {
scout = '[[File:Scout_icon.png|link=Scout|width=18x18]]',
scout = '[[File:Scout_icon.png|link=Scout|width=18x18]]',
Line 456: Line 456:
}
}


local parts = {}
local fields = {}
for part in value:gmatch("%w+") do
for field in input_string:gmatch("([^,]+)") do
table.insert(parts, part)
table.insert(fields, field)
end
end


local profession = {parts[1], parts[2]}
local result = {}
local knowledge = {parts[3], parts[4]}
local quest = {parts[5], parts[6]}
local min_weapon_strength = {parts[7], parts[8]}


for i = 1, #fields, 2 do
return string.format(
"%s %s, %s %s, %s %s, %s %s",
local key = fields[i]
icon_map[profession[1]], profession[2],
local value = fields[i+1]
icon_map[knowledge[1]], knowledge[2],
icon_map[quest[1]], quest[2],
if not value then
-- Do nothing
icon_map[min_weapon_strength[1]], min_weapon_strength[2]
)
else
local icon = icon_map[key]
if type(value) == "number" then
table.insert(result, string.format("%s %d", icon, math.floor(value)))
else
table.insert(result, string.format("%s %s", icon, value))
end
end
end

return table.concat(result, ", ")
end
end