local function sumFormat(a)
local b, e = ('%d'):format(a):gsub('^%-', '')
local c = b:reverse():gsub('%d%d%d', '%1.')
local d = c:reverse():gsub('^%.', '')
return (e == 1 and '-' or '')..d
end
print(sumFormat(1231231)) --> 1.231.231
print(sumFormat(72312)) --> 72.312
print(sumFormat(812381231231812)) --> 812.381.231.231.812