模块:NPCShop

可在模块:NPCShop/doc创建此模块的帮助文档

local p={}

function p.expand(frame)
	local args = (frame == mw.getCurrentFrame() and frame.args) or frame
	local str = args['str'] or ''
	if (str=='') then 
		return ''
	end
	local output = {}
	local result = ''
	local strrow = mw.text.split(str, '+\n')

	for i=1, #strrow do
		local irow = mw.text.split(strrow[i], ',')
		local shopitem = mw.text.split(irow[1], '*')
		local tablerow = '|'..frame:expandTemplate{title='NPC图标', args={shopitem[1], type='商店'}}..'||'..shopitem[2]..'||'
		local priceitem = mw.text.split(irow[2], '、')
		for ipt=1, #priceitem do
			local price = mw.text.split(priceitem[ipt], '*')
			tablerow = tablerow..frame:expandTemplate{title='NPC图标', args={price[1], price[2]}}
		end
		tablerow = tablerow..'||'..irow[3]..'||'..irow[4]..'||'..irow[5]
		output[i] = tablerow
	end
	result = table.concat(output, '\n\n|-\n\n')
	mw.log(result)
	return result
end

return p