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( |
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 |
local fields = {} |
||
for |
for field in input_string:gmatch("([^,]+)") do |
||
table.insert( |
table.insert(fields, field) |
||
end |
end |
||
local |
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( |
|||
local key = fields[i] |
|||
local value = fields[i+1] |
|||
icon_map[knowledge[1]], knowledge[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 |
||