本WIKI除首页和部分特殊页面外编辑权限开放。
为了方便未来的使用,务必收藏哦~
感谢 一直在作死的千岛酱对主页的设计支持,期待更多家主大人加入妖怪屋WIKI~
编辑帮助萌新问答区

全站通知:

模块:图标

来自阴阳师妖怪屋WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块的文档可以在模块:图标/doc创建

local p={}

function p.expandSet(frame)
	local args = (frame == mw.getCurrentFrame() and frame.args) or frame
	
	local str = args['str'] or ''      -- 待处理字符串
	local pname = args['pname'] or ''  -- 输出参数名称
	if (str=='' or pname=='') then 
		return ''
	end
	local paratable = {}
	local result = ''
	
	local strtable = mw.text.split(str, '、')
	local itemtable = {}
	local itemname, itemcount = '', 0
	for i = 1, #strtable do
		itemtable = mw.text.split(strtable[i],'*')
		itemname = itemtable[1]
		paratable[#paratable+1] = itemname
	end
	local parastr = table.concat(paratable,'、')
	result = frame:callParserFunction{ name = '#set', args = { pname..'='..parastr,'+sep=、'} }
	mw.log(result)
	return result
end

function p.expandTemplate(frame)
	local args = (frame == mw.getCurrentFrame() and frame.args) or frame
	
	local str = args['str'] or ''      -- 待处理字符串
	if (str=='') then 
		return ''
	end
	local ptype = args['ptype'] or ''  -- 图标模板类型
	local sep = args['sep'] or ''      -- 输出的分隔符
	local paratable = {}
	local resulttable = {}
	local result = ''
	
	local strtable = mw.text.split(str, '、')
	local itemtable = {}
	local itemname, itemcount = '', 0
	for i = 1, #strtable do
		itemtable = mw.text.split(strtable[i],'*')
		itemname = itemtable[1]
		itemcount = itemtable[2]
		if (ptype=='') then
			resulttable[#resulttable+1] = frame:expandTemplate{ title = '图标', args = { itemname, itemcount} }
		else
			resulttable[#resulttable+1] = frame:expandTemplate{ title = '图标', args = { ptype, itemname, itemcount} }
		end
	end
	result = table.concat(resulttable,sep)
	mw.log(result)
	return result
end

return p