Echo a list in a miniconsole
Echo a list in a miniconsole
Is there a way to echo an entire list (table) to a miniconsole other than parsing the list and sending the elements individually?
Re: Echo a list in a miniconsole
You can use table.concat to turn the list into a string. table.concat(myTbl, ", ") will produce "This, that, the other' if the table is { "this", "that", "the other" }
Alternately, if you're just looking for a quick dump you can use myMiniConsole:display(myTbl) if it's a Geyser miniconsole.
Alternately, if you're just looking for a quick dump you can use myMiniConsole:display(myTbl) if it's a Geyser miniconsole.
Re: Echo a list in a miniconsole
Thanks for the response!
That worked, but not quite as desired (though probably as expected ... )
myTable = {"1", "2"}
HelloWorld:display(myTable)
results in {"1","2"} being echoed to the miniconsole.
What I was hoping for was
1
2
That worked, but not quite as desired (though probably as expected ... )
myTable = {"1", "2"}
HelloWorld:display(myTable)
results in {"1","2"} being echoed to the miniconsole.
What I was hoping for was
1
2
Re: Echo a list in a miniconsole
By the way, I am guessing the answer is parsing the list and sending the output one item at a time, but I am concerned about the overhead/efficiency of that.
Re: Echo a list in a miniconsole
nah, just use HelloWorld:echo(table.concat(myTable, "\n"))
Re: Echo a list in a miniconsole
That being said unless you're echoing out tables with thousands of items every prompt or something you should be fine doing the processing yourself.
Re: Echo a list in a miniconsole
Well, a dozen maybe, so ... . I have a couple of different options now, though. Thank you!
One last question, is there any way to have the echo start at the bottom of the miniConsole and work up? I think I can figure a way around this wiht 'moveCursor', but thought I would ask.
One last question, is there any way to have the echo start at the bottom of the miniConsole and work up? I think I can figure a way around this wiht 'moveCursor', but thought I would ask.
Re: Echo a list in a miniconsole
None I'm aware of, no.
Re: Echo a list in a miniconsole
Well, nothing a little arithmatic and movcurso can't solve, I think ...
Thanks again for the help.
Thanks again for the help.
Re: Echo a list in a miniconsole
Interestingly, insertText reverses the order. Here is a comparison:
But I can't get moveCursor to work:
Code: Select all
myTable = {"zzz", "1", "2", "Bananna", "f", "GGG"}
clearWindow("HelloWorld")
--moveCursor("HelloWorld", 0, 5)
--moveCursorDown("HelloWorld", 5, false)
for _, v in ipairs(myTable) do
--insertText("HelloWorld", _ .. " " .. v .. "\n")
echo("HelloWorld", _ .. " " .. v .. "\n")
end
Code: Select all
myTable = {"zzz", "1", "2", "Bananna", "f", "GGG"}
clearWindow("HelloWorld")
--moveCursor("HelloWorld", 0, 5)
--moveCursorDown("HelloWorld", 5, false)
for _, v in ipairs(myTable) do
insertText("HelloWorld", _ .. " " .. v .. "\n")
--echo("HelloWorld", _ .. " " .. v .. "\n")
end
Code: Select all
myTable = {"zzz", "1", "2", "Bananna", "f", "GGG"}
clearWindow("HelloWorld")
moveCursor("HelloWorld", 0, 5)
--moveCursorDown("HelloWorld", 5, false)
for _, v in ipairs(myTable) do
insertText("HelloWorld", _ .. " " .. v .. "\n")
--echo("HelloWorld", _ .. " " .. v .. "\n")
end