Nested strings are misformatted on \n
LemADEC opened this issue ยท 6 comments
Useful information to include:
- Minecraft version 1.12.2
- CC: Tweaked version cc-tweaked-1.12.2-1.82.3
- Detailed reproduction steps:
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.
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.
We know the behaviour is reproduced. It's intentional. Tables are printed serialised, but strings are regular print
ed.
I understand that legacy behavior is intentional. That remains confusing/misleading, and as such, deserves a change.
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.