跳转到内容

模块:物品用途

来自Wymbot 共创站
NotBot​(留言 | 贡献)2026年10月24日 (六) 12:01的版本 (建立模块化物品展示及用户提供的测试数据(不迁移旧掉落))
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

此模块的文档可以在模块:物品用途/doc创建

local C = require('模块:物品通用')
local D = require('模块:物品数据')
local p = {}
function p.main(frame)
    local c = C.context(frame)
    if not c.enabled then return '' end
    local result, cats, pieces = D.getUses(c.name), {}, {}
    if result.status == 'error' then pieces[#pieces + 1] = C.diagnostic(result); cats[#cats + 1] = '物品数据异常的页面'
    elseif result.status == 'known' then
        local links = {}
        for _, name in ipairs(result.products) do links[#links + 1] = C.link(name) end
        pieces[#pieces + 1] = "'''用于合成:'''" .. table.concat(links, '、')
        cats[#cats + 1] = '能作为合成材料的物品'
    elseif result.status == 'pending' then pieces[#pieces + 1] = '合成材料用途数据待补充。' end
    local action = c.text('物品作用')
    if action then pieces[#pieces + 1] = action; cats[#cats + 1] = '有一定用途的物品' end
    if #pieces == 0 then pieces[1] = '暂无其他用途说明。' end
    return C.finish(c, 'uses', C.heading(c, '有什么用?') .. table.concat(pieces, '\n\n'), cats)
end
return p