모듈:Iloop

리버티게임, 모두가 만들어가는 자유로운 게임
백괴게임>Gustmd7410님의 2018년 7월 13일 (금) 18:23 판


모듈 설명문서[보기] [편집] [역사] [새로 고침]
이 부분의 본문은 틀:loop입니다.


local hook = require('모듈:Hooks')

return {
	loop = function(frame)
		local text = frame.args[1]
		local finish = tonumber(frame.args[2])
		local times = tonumber(frame.args[3]) or 1
		local from = tonumber(frame.args[4]) or 1
		
		text = text:gsub('{{#keep#:(.-)}}', '{{%1}}')
		text = hook.parse(text, 'param', function(frame)
			if frame.args[2]
				then return '{{{' .. frame.args[1] .. '|' .. frame.args[2] .. '}}}'
				else return '{{{' .. frame.args[1] .. '}}}'
			end
		end)
		
		local value = ''
		for index = from, finish, times do
			value = value .. hook.parse(text, 'index', index)
		end
		
		return frame:preprocess(value)
	end
}