how to print to console when you reach the limit of LocalisedString
Posted: Wed Dec 17, 2025 7:30 pm
So, I want to print a list of entities on the console, that works well but we can't scroll the console output so I decided to instead of doing one entity per line I concat all into one line. And then... I discover I can't concat more than 20 (well actually 19 cause the first "" count...) with LocalisedString array. I end up solving the problem using deeper level... I really don't get why there is a limit of 20 for the array, for the recursion okay why not but for the array ??? Anyway here some snipped if you know better please advice
Code: Select all
local i = 1
local line = {""}
for type, qualities in pairs(entities_count) do
if i > 20 then
print(line)
i = 1
line = {""}
end
local tmp = {"", " ⚙ ", prototypes.entity[type].localised_name}
for quality_name, count in pairs(qualities) do
local quality = prototypes.quality[quality_name]
local c = quality.color
local color = string.format("#%.2x%.2x%.2x%.2x", c.a * 255, c.r * 255, c.g * 255, c.b * 255)
table.insert(tmp, {"", string.format(": [color=%s]", color), quality.localised_name, string.format("[/color]: %d", count)})
end
table.insert(line, tmp)
i = i + 1
end
print(line)