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(arg)
function parse.requirements_func(value)
local icon_map = {
local icon_map = {
quest = [[File:Quests_icon.png|link=Quests|width=18x18]],
scout = [[File:Scout_icon.png|link=Scout|width=18x18]],
profession = [[File:Scout_icon.png|link=Scout|width=18x18]],
knowledge = [[File:Knowledge_icon.png|link=Knowledge|width=18x18]],
knowledge = [[File:Knowledge_icon.png|link=Knowledge|width=18x18]],
quest = [[File:Quests_icon.png|link=Quests|width=18x18]],
min_weapon_strength = [[File:Scout_icon.png|link=Scout|width=18x18]]
}
}
local requirement_pairs = {}
for key, value in pairs(arg) do
table.insert(requirement_pairs, string.format("%s %s", icon_map[key], value))
end


local _, profession, knowledge, quest, min_weapon_strength =
return table.concat(requirement_pairs, " ")
input:gmatch("(.-),(.-)%.-%s+(.-),%.-%s+(.-),%.-%s+(.-)")

if not profession or not knowledge or not quest or not min_weapon_strength then
return "Invalid input"
end

local profession_name, profession_value = profession:match("(%w+)%s+(%S+)")

local knowledge_value = knowledge
local quest_value = quest
local min_weapon_strength_value = min_weapon_strength

local result = {
icon_map[profession] .. " " .. profession_value,
icon_map.knowledge .. " " .. knowledge_value,
icon_map.quest .. " " .. quest_value,
icon_map["min_weapon_strength"] .. " " .. min_weapon_strength_value
}

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


parse.requirements = {
parse.requirements = {
name = 'requirements',
name = 'requirements',
func = {name = parse.requirements_func, params = {Infobox.raw_param('requirements')}},
func = parse.requirements_func,
smw_property = 'Requirements',
smw_property = 'Requirements',
category_incomplete = 'Needs requirements'
category_incomplete = 'Needs requirements'