打开/关闭搜索
搜索
打开/关闭菜单
1K
5.2K
4
8.2K
星砂岛百科
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
上传文件
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
本站正在进行早期测试,目前仍存在许多内容的缺失。
查看“︁模块:Item”︁的源代码
来自星砂岛百科
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
←
模块:Item
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:已验证邮箱用户
您没有权限编辑
模块
命名空间内的页面。
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
local common = require('Module:Common') local item_common = require('Module:ItemCommon') local p = {} local name_data local desc_data local mapping local function normalize_key(value) return item_common.normalizeKey(value) end local function load_name_data() if name_data then return end name_data, mapping = item_common.loadDomainData('数据:Item/item_name_index.json', '数据:Item/item_mapping.json') end local function load_desc_data() if desc_data then return end desc_data = common.loadJsonData('数据:Item/item_desc_index.json') or {} end local function resolve_input_key(value) local resolved = common.trim(value) if resolved == '' then resolved = common.getCurrentTitleText() end return resolved end local function find_name_record(key) load_name_data() return item_common.findRecord(name_data, mapping, key) end local function find_desc_record(key) load_name_data() load_desc_data() local name_record = find_name_record(key) if name_record and name_record.id then local by_id = desc_data[normalize_key(name_record.id)] if by_id then return by_id end end return item_common.findRecord(desc_data, mapping, key) end local function get_item_id(key) load_name_data() local record = find_name_record(key) if record and record.id then return record.id end local resolved = resolve_input_key(key) local normalized = normalize_key(resolved) local mapped_id = mapping.name_to_id and mapping.name_to_id[normalized] if mapped_id then return mapped_id end return resolved end local function get_item_name(key) load_name_data() local record = find_name_record(key) if record and common.trim(record.name) ~= '' then return common.trim(record.name) end local item_id = get_item_id(key) if item_id ~= '' then local mapped_name = mapping.id_to_name and mapping.id_to_name[normalize_key(item_id)] or '' if common.trim(mapped_name) ~= '' then return common.trim(mapped_name) end end return resolve_input_key(key) end function p.getName(frame) return get_item_name(common.getArg(frame, 1, '')) end function p.getId(frame) return get_item_id(common.getArg(frame, 1, '')) end function p.getDescription(frame) local record = find_desc_record(common.getArg(frame, 1, '')) if not record then return '' end return common.toText(record.description) end function p.renderItem(frame) local key = common.getArg(frame, 1, '') if common.trim(resolve_input_key(key)) == '' then return '' end local display_name = get_item_name(key) local item_id = get_item_id(key) local size = common.trim(common.getArg(frame, 'size', '')) if size == '' then size = '24' end local suffix = common.trim(common.getArg(frame, 2, '')) local custom_link = common.trim(common.getArg(frame, 'link', '')) local css_class = common.trim(common.getArg(frame, 'class', '')) local class_name = 'itemtemplate' if css_class == 'block' then class_name = class_name .. ' itemtemplateblock' end local file_name = item_id if file_name == '' then file_name = display_name end local link_text if custom_link ~= '' then link_text = ('[[%s|%s]]'):format(custom_link, display_name) else link_text = ('[[%s]]'):format(display_name) end local out = {} out[#out + 1] = ('<span class="%s">'):format(class_name) out[#out + 1] = '<span class="item-icon-container">' out[#out + 1] = ('[[File:%s.png|%sx%spx|link=]]'):format(file_name, size, size) out[#out + 1] = '</span>' out[#out + 1] = '<span class="item-text">' out[#out + 1] = link_text if suffix ~= '' then out[#out + 1] = (' (%s)'):format(suffix) end out[#out + 1] = '</span>' out[#out + 1] = '</span>' return table.concat(out) end return p
该页面嵌入的页面:
模块:Item/doc
(
查看源代码
)
返回
模块:Item
。
查看“︁模块:Item”︁的源代码
来自星砂岛百科