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

Материал из Википедии — свободной энциклопедии
Перейти к навигации Перейти к поиску
Документация
local function DEBUG(indata, shift)
	if shift == nil then
		shift = ''
	end
	if string.len(shift) > 100 then
		return 'table'
	end
	
	if type(indata) == 'table' then
		local res = '{'
		for key, value in pairs(indata) do
			res = res .. shift .. key .. '='
			if type(value) ~= 'table'
			then
				res = res .. DEBUG(value) .. '<br>'
			else
				res = res .. '<br>' .. DEBUG(value, shift .. '&nbsp;&nbsp;&nbsp;') .. '<br>'
			end
		end
		return res .. '}'
	end

	if type(indata) == 'boolean' then
		if indata then
			return 'true'
		else
			return 'false'
		end
	end

	if type(indata) == 'string' then
		return indata
	else
		return tostring(type(indata))
	end
end

return DEBUG