模块:Livestock
来自星砂岛百科
更多操作
概述
Livestock 提供畜牧动物域的数据读取、配方列表与成长阶段渲染,供 {{Infobox livestock}} 与 {{AnimalRecipes}} 调用。
用法
{{#invoke:Livestock|getField|奶牛|mount_speed}}
{{#invoke:Livestock|renderGrowStages|奶牛}}
{{#invoke:Livestock|productionRecipeList|奶牛}}
函数
getField:读取条目字段,默认查当前页面标题。renderGrowStages:渲染成长阶段图片区块。processRecipeList:渲染加工配方列表。productionRecipeList:渲染产出配方列表。machineList:返回关联机器名称列表。
数据来源
local item_common = require('Module:ItemCommon')
local common = require('Module:Common')
local p = {}
item_common.buildRecipeDomain(p, '数据:Livestock/livestock_index.json')
function p.renderGrowStages(frame)
local key = common.getArg(frame, 1, '')
local record = p.findRecord(key)
if not record or type(record) ~= 'table' then
return ''
end
local stages = record.grow_stages
if not stages or type(stages) ~= 'table' or #stages == 0 then
return ''
end
local out = {}
for _, stage in ipairs(stages) do
local label = stage.display_name or stage.name or ''
local icon = stage.icon or ''
if label ~= '' and icon ~= '' and common.filePageExists(icon) then
out[#out + 1] = '<section>'
out[#out + 1] = '<label>' .. label .. '</label>'
out[#out + 1] = '<image source="image_' .. stage.name .. '">'
out[#out + 1] = '<default>' .. icon .. '</default>'
out[#out + 1] = '</image>'
out[#out + 1] = '</section>'
end
end
return table.concat(out, '\n')
end
return p