模組討論:CGroupViewer

最新留言:3年前由Xiplus在话题編輯請求 2021-03-13内发布

編輯請求 2020-01-06 编辑

  请求已拒绝

把函數main改成這樣:

function z.main( frame )
	local name = frame.args[1]
	if not name or name == '' then
		return ''
	end
	local data = require( 'Module:CGroup/' .. name )
	if type( data ) ~= 'table' or not data.name or data.name == '' then
		return error.error{ '指定-{zh-hans:模块;zh-hant:模組}-“' .. name .. '”不是有效的转换组' }
	end
	if data.name ~= name then
		return frame:expandTemplate{ title = 'Template:CGroup redirect', args = { 'Module:CGroup/' .. data.name } }
	end
	local text = '<strong>-{H|zh-hans:模块;zh-hant:模組}-以下是[[Wikipedia:字詞轉換處理/公共轉換組|公共转换组]]“' .. data.description .. '”。</strong>\n\n'
	for i, v in ipairs( data.content ) do
		if v.type == 'text' then
			text = text .. makeText( frame, v )
		elseif v.type == 'item' then
			text = text .. makeItem( frame, v )
		end
	end
	text = text .. '[[Category:公共轉換組模板|' .. name .. ']][[Category:公共转换组模块|' .. name .. ']]'
	return text
end

-- Sunny00217 2020年1月6日 (一) 15:21 (UTC)回复

 未完成,嘗試修改後部分頁面出現以下錯誤:「Lua錯誤:not enough memory。」。--Xiplus#Talk 2020年1月6日 (一) 23:01 (UTC)回复

那如果改成這樣呢:

function z.main( frame )
	local name = frame.args[1]
	if not name or name == '' then
		return ''
	end
	local data = require( 'Module:CGroup/' .. name )
	if type( data ) ~= 'table' or not data.name or data.name == '' then
		return error.error{ '指定-{zh-hans:模块;zh-hant:模組}-“' .. name .. '”不是有效的转换组' }
	end
	if data.name ~= name then
		return frame:expandTemplate{ title = 'Template:CGroup redirect', args = { 'Module:CGroup/' .. data.name } }
	end
	local pieces = { '-{H|zh-hans:模块;zh-hant:模組}-<strong>以下是[[Wikipedia:字詞轉換處理/公共轉換組|公共转换组]]“' .. data.description .. '”。</strong>\n\n' }
	for i, v in ipairs( data.content ) do
		if v.type == 'text' then
			table.insert( pieces, makeText( frame, v ) )
		elseif v.type == 'item' then
			table.insert( pieces, makeItem( frame, v ) )
		end
	end
	table.insert( pieces, '[[Category:公共轉換組模板|' .. name .. ']][[Category:公共转换组模块|' .. name .. ']]' )
	return table.concat( pieces )
end

-- Sunny00217 2020年1月7日 (二) 13:42 (UTC)回复


編輯請求 2021-03-13 编辑

  请求已处理--Xiplus#Talk 2021年3月23日 (二) 02:18 (UTC)回复

加入Bot use warning。--Xiplus#Talk 2021年3月13日 (六) 02:24 (UTC)回复

返回到“CGroupViewer”页面。