Модуль:Песочница/CupIvan/debug

Материал из Википедии — свободной энциклопедии
Перейти к навигации Перейти к поиску
Документация
-- вывод отладочной информации
function debug(a, offset)
	if a == nil then return 'NIL' end
	if offset == nil then offset = '' end
	if type(a) == 'boolean' then if a then return 'TRUE' else return 'FALSE' end end
	if type(a) == 'function' then return 'FUNCTION' end
	if type(a) ~= 'table' then return a end
	if string.len(offset) > 100 then return 'TABLE' end
	local st = ''
	for k, v in pairs(a)
	do
		st = st .. offset .. k .. '='
		if type(v) ~= 'table'
		then
			st = st .. debug(v) .. '<br>'
		else
			st = st .. '<br>' .. debug(v, offset .. '&nbsp;&nbsp;&nbsp;') .. '<br>'
		end
	end
	return st
end

return debug