Zelda Top Logo.jpg

共建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, num=itemcount} }
		else
			resulttable[#resulttable+1] = frame:expandTemplate{ title = '图鉴按钮', args = { itemname, num=itemcount, type=ptype} }
		end
	end
	result = table.concat(resulttable,sep)
	mw.log(result)
	return result
end

function p.expandWeaponTemplate(frame)
	local args = (frame == mw.getCurrentFrame() and frame.args) or frame
	
	local str = args['str'] or ''      -- 待处理字符串
	if (str=='') then 
		return ''
	end
	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]
		resulttable[#resulttable+1] = frame:expandTemplate{ title = '武器图鉴/材料', args = { itemname, itemcount} }
	end
	result = table.concat(resulttable,sep)
	mw.log(result)
	return result
end

return p