Module:OutputBuffer: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>Jackmcbarn
make a printf-like too
meta>Jackmcbarn
change output order and fix bug
Line 1: Line 1:
return function()
return function()
local buffer = {}
local buffer = {}
return function(text)
return function(sep)
local b = buffer
buffer = {}
return table.concat(b, sep)
end,
function(text)
buffer[#buffer + 1] = text
buffer[#buffer + 1] = text
end,
end,
function(...)
function(...)
buffer[#buffer + 1] = string.format(...)
buffer[#buffer + 1] = string.format(...)
end,
function(sep)
local b = buffer
buffer = nil
return table.concat(b, sep)
end
end
end
end

Revision as of 00:06, 26 June 2014

Documentation for this module may be created at Module:OutputBuffer/doc

return function()
	local buffer = {}
	return function(sep)
		local b = buffer
		buffer = {}
		return table.concat(b, sep)
	end,
	function(text)
		buffer[#buffer + 1] = text
	end,
	function(...)
		buffer[#buffer + 1] = string.format(...)
	end
end