This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
HDeffo's profile picture

Adjust table output in Lua program

Started by HDeffo, 15 May 2016 - 05:43 PM
HDeffo #1
Posted 15 May 2016 - 07:43 PM
more nitpicking than anything so I doubt this will be considered but suggesting it none the less. The Lua program current serializes table output to make it easy to read. This is a really nice feature however due to the limited size constraints the tables quickly because unreadable by being pushed off the screen. I am suggesting instead it be changed to something like

print( textutils.serialize(output):gsub("\n","") )
now obviously that's not the cleanest solution and leaves a ton of needless spaces behind but its the easiest example of what I am suggesting. Essentially I believe the Lua program should try to condense the serialized tables as much as possible before printing so they are easier to read
Edited on 15 May 2016 - 05:43 PM
Bomb Bloke #2
Posted 16 May 2016 - 12:29 AM
An alternative would be:

textutils.pagedPrint( serialised )

Granted scrolling might take a while for longer tables, but there's always Ctrl + T.
Luca_S #3
Posted 16 May 2016 - 09:54 PM
Maybe something like a
textutils.compactSerialise()
function would be nice.
Anavrins #4
Posted 16 May 2016 - 10:26 PM
I'd say in the same style that serializeJSON(t, true) returns a different format, serialize(t, true) could return in a compact version.
Although, so far I've been using serialize(t):gsub("\n%s*", ""), the only issue with that is of course, any string value that contains \n will be affected.
Edited on 16 May 2016 - 08:44 PM