Page 1 of 1

how to print to console when you reach the limit of LocalisedString

Posted: Wed Dec 17, 2025 7:30 pm
by Stargateur
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)

Re: how to print to console when you reach the limit of LocalisedString

Posted: Wed Dec 17, 2025 7:49 pm
by boskid
LocalisedString's recursion limit being 20 levels is documented since 1.1.22. Please consider not splicing localised strings and instead using log() for whatever debugging purpose you need it.

Re: how to print to console when you reach the limit of LocalisedString

Posted: Wed Dec 17, 2025 8:02 pm
by Stargateur
boskid wrote: Wed Dec 17, 2025 7:49 pm LocalisedString's recursion limit being 20 levels is documented since 1.1.22.
I talk more about parameter limit than recursion limit and I never imply it was new
boskid wrote: Wed Dec 17, 2025 7:49 pm Please consider not splicing localised strings
What ? my very problem is I'm forced to do this - - I wish I could just do "utils.get_translation(localisation_string)"
boskid wrote: Wed Dec 17, 2025 7:49 pm instead using log() for whatever debugging purpose you need it.
That not debugging and that irrelevant, debugging or not the problem is here. And honestly I wouldn't use localization for debug output

---

Well I end up with this:

Code: Select all

  line = ""
  for type, qualities in pairs(entities_count) do
    for quality_name, count in pairs(qualities) do
      local quality = prototypes.quality[quality_name]
      line = string.format("%s[entity=%s,quality=%s] %d ", line, prototypes.entity[type].name,  quality.name, count)
    end
  end
  print(line)
Not what I wanted but work

Re: how to print to console when you reach the limit of LocalisedString

Posted: Wed Dec 17, 2025 8:05 pm
by Rseding91
If you have so much data to show that you can't fit it all on-screen consider making a custom GUI to show it runtime. The chat window is and was never meant as a place to output that much information. It was meant for short one-off bits of information (hence why it fades out, and has a limited amount of space shown on screen).