打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

本站正在进行早期测试,目前仍存在许多内容的缺失。

模块:Seed

来自星砂岛百科

概述

Seed 提供种子域的数据读取与配方列表渲染,供 {{Infobox seed}}{{SeedRecipes}} 调用。

用法

{{#invoke:Seed|getField|土豆种子|type_display}}
{{#invoke:Seed|processRecipeList|土豆种子}}
{{#invoke:Seed|productionRecipeList|土豆种子}}

函数

  • getField:读取条目字段,默认查当前页面标题。
  • processRecipeList:渲染加工配方列表。
  • productionRecipeList:渲染产出配方列表。
  • machineList:返回关联机器名称列表。

数据来源


local item_common = require('Module:ItemCommon')

local p = {}

item_common.buildRecipeDomain(p, '数据:Seed/seed_index.json')

local base_get_field = p.getField

function p.getField(frame)
    local field = mw.text.trim((frame.args and frame.args[2]) or '')
    if field == 'crop_item_link' then
        local raw = base_get_field(frame)
        local key = mw.text.trim((frame.args and frame.args[1]) or '')
        local crop_name = ''
        local crop_id = ''

        frame.args[2] = 'crop_item_name'
        crop_name = base_get_field(frame)
        frame.args[2] = 'crop_item_id'
        crop_id = base_get_field(frame)
        frame.args[2] = field

        if mw.text.trim(crop_name) == '' then
            return ''
        end
        if mw.text.trim(crop_id) ~= '' or mw.text.trim(key) ~= '' then
            return '[[' .. crop_name .. ']]'
        end
        return crop_name
    end

    return base_get_field(frame)
end

return p