CC: Tweaked

CC: Tweaked

42M Downloads

Nested strings are misformatted on \n

LemADEC opened this issue ยท 6 comments

commented

Useful information to include:

  • Minecraft version 1.12.2
  • CC: Tweaked version cc-tweaked-1.12.2-1.82.3
  • Detailed reproduction steps:
    image
    When printing a string in the LUA console, the '\n' are displayed as actual new lines. The print method behave the same.

When said string is in an array, the backslash character remains in Lua console (see above screenshot). The print method only shows the table reference in that case, so we can't compare.

commented

The backslash is there to indicate the string continues in the next line.

commented

Behavior is also reproduced on 1.7.10 ComputerCraft1.75.
Either the backslash is always there, or never. It shouldn't be 'sometime'.
Personally, I prefer OC approach to showing string variables escaped in the LUA console. It's more compact and explicit.

commented

We know the behaviour is reproduced. It's intentional. Tables are printed serialised, but strings are regular printed.

commented

I understand that legacy behavior is intentional. That remains confusing/misleading, and as such, deserves a change.

commented

From what I understand, this mostly boils down to "use textutils.serialise all the time", rather than our current behaviour of only doing it for tables.

I'd definitely be in favour of that - it's in line with what most REPLs do. However, I don't know if this could potentially be more confusing for beginners. Consider running handle:read() in the REPL - this'll print an escaped string, which is harder to "decode" mentally. We could always add a setting for this, but something worth discussing before making any changes.

Truth be told, it's probably worth just switching the entire display mechanism over to a modified version of mbs's. This way we can handle recursive tables, functions, etc... too.

commented

Handling nested would be a very good thing to add!