- 致编者:请牢记我们的域名wiki.mcbe-dev.net!
- 致编者:欢迎加入本Wiki的官方交流QQ群或Discord服务器!
- 基岩版1.19.31现已发布!(了解更多)
- Inner Core现已支持Xbox模组联机!(了解更多)
- 如果您是第一次来到本Wiki,欢迎注册一个账户
- 点击顶部的“编辑”或“编辑源代码”按钮即可编辑当前页面
- 请知悉:在不登录时也可以编辑和新建页面,但是您当前的IP地址会记录在编辑历史中
Module:Other uses
来自Minecraft基岩版开发Wiki
local mHatnote = require('Module:Hatnote')
local mHatlist = require('Module:Hatnote list')
local mArguments --initialize lazily
local mTableTools --initialize lazily
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}
-- Produces standard {{other uses}} implementation
function p.otheruses(frame)
mArguments = require('Module:Arguments')
mTableTools = require('Module:TableTools')
local args = mTableTools.compressSparseArray(mArguments.getArgs(frame))
local title = mw.title.getCurrentTitle().prefixedText
return p._otheruses(args, {title=title})
end
--Implements "other [x]" templates with otherText supplied at invocation
function p.otherX(frame)
mArguments = require('Module:Arguments')
mTableTools = require('Module:TableTools')
local x = frame.args[1]
local args = mTableTools.compressSparseArray(
mArguments.getArgs(frame, {parentOnly = true})
)
local options = {
title = mw.title.getCurrentTitle().prefixedText,
otherText = x
}
return p._otheruses(args, options)
end
-- Main generator
function p._otheruses(args, options)
--Type-checks and defaults
checkType('_otheruses', 1, args, 'table', true)
args = args or {}
checkType('_otheruses', 2, options, 'table')
if not (options.defaultPage or options.title) then
error('"_otheruses"选项表中未提供默认标题数据', 2)
end
local emptyArgs = true
for k, v in pairs(args) do
if type(k) == 'number' then emptyArgs = false break end
end
if emptyArgs then
args = {
options.defaultPage or
mHatnote.disambiguate(options.title, options.disambiguator)
}
end
--Generate and return hatnote
local image = '[[File:Disambig_gray.svg|25px|link=Wikipedia:消歧义]]'
local text = mHatlist.forSeeTableToString({{
use = options.otherText and "其他" .. options.otherText or nil,
pages = args
}})
text = image .. ' ' .. text
return mHatnote._hatnote(text)
end
return p