Make lua.lua display all tables #437
Conversation
At the moment, lua.lua can only display who are work with textutils.serialise(). With this PR, all table will be displayed.
I've been meaning to PR something like this for a while, so
|
@SquidDev You mean, if __tostring is a function in a child table then call it and print the result? btw. it fails not with _G. |
@Wilma456 No, it should look in the metatable for the Ahh, you're not even recursing over nested tables, so you won't get any issues. Ideally you'd recur until you find something you've hit already, like textutils.serialize does. In fact, I'd use that as the basis for the implementation, and build from there. |
Is this a good idea to not show contents of nested tables? |
@Wojbie has a good point, |
@Lupus590 So you think, I should not show the content of subtables? |
What did you think, what's the best way, to show, that it is a table who provide a __tostring() and not a string? btw: |
Part of the point of the metamethod is that it's discreet about what it's doing.
Edit: For moving to textutils, I would rename the function to a more generic usecase descriptor. |
Changes are now done! |
@@ -19,15 +19,25 @@ local tEnv = { | |||
setmetatable( tEnv, { __index = _ENV } ) | |||
|
|||
local function displayTable( tDisplay ) |
Lupus590
Sep 11, 2017
Contributor
The function is called displayTable but returns a string instead of doing its name sake.
If the only use of the resulting string is to print it (for this program at least) then in my mind the function should do the actual printing. If the output string does get used for something else then this function should be renamed.
The function is called displayTable but returns a string instead of doing its name sake.
If the only use of the resulting string is to print it (for this program at least) then in my mind the function should do the actual printing. If the output string does get used for something else then this function should be renamed.
At the moment, lua.lua can only display who are work with textutils.serialise(). With this PR, all table will be displayed.
Here's a screen how it looks, if textutils.serialise() not working:
