模組:沙盒/Oudoubleyang/arguments
模块文档[创建]
您可能想要创建本Scribunto模块的文档。 编者可以在本模块的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 请在/doc子页面中添加分类。本模块的子页面。 |
local p={}
function p.ar(frame)
local args
local str
if frame == mw.getCurrentFrame() then
-- called via #invoke
args = frame.args
can_call_parse = true
else
-- called from another module
args = frame
if type(args) ~= type({}) then args = {frame} end
end
if args[1] then str = args[1] else str = args['1'] end
if args['start'] then
head = args['start']
else
if args['length'] then
length = tonumber(args['length'])
else
if args[2] then second = args[2] else second = args['2'] end
if type(tonumber(second)) == 'number' then length = tonumber(second) else head = second end
end
end
if length then
return length
else
return head
end
end
return p