-
Notifications
You must be signed in to change notification settings - Fork 9
fText: TableMaker: Examples
Damian Monogue edited this page Jun 17, 2021
·
4 revisions
local TableMaker = require("MDK.ftext").TableMaker
testMaker = TableMaker:new()
-- Though by itself, it won't really do much. So let's add a few columns to it
testMaker:addColumn({name = "col1", width = 15, textColor = "<orange>"})
testMaker:addColumn({name = "col2", width = 20, textColor = "<green>"})
testMaker:addColumn({name = "col3", width = 30, textColor = "<purple>"})
-- These are fairly minimal format options, but are enough for our demonstration purposes.
-- So now we've described the formatting for our table, let's add some information to display and print it out.
testMaker:addRow({"row 1 col 1", "row 1 col 2", "row 1 col 3"})
testMaker:addRow({"row 2 col 1", "row 2 col 2", "row 2 col 3"})
testMaker:addRow({"row 3 col 1", "row 3 col 2", "row 3 col 3"})
cecho(testMaker:assemble())
Not bad for 8 lines of code, eh?
testMaker:replaceColumn({name = "col1b", width = 10}, 1)
cecho(testMaker:assemble())
testMaker:replaceRow({"blah", "", "feh"},2)
cecho(testMaker:assemble())
testMaker.printHeaders = false
cecho(testMaker:assemble())
testMaker.frameColor = "<red>"
cecho(testMaker:assemble())
testMaker.separatorColor = "<blue>"
cecho(testMaker:assemble())
local TableMaker = require("MDK.ftext").TableMaker
testMaker = TableMaker:new({
title = "Test Table",
printTitle = true,
titleColor = "<red>",
printHeaders = false,
separateRows = false,
})
testMaker:addColumn({name = "col1", width = 15, textColor = "<orange>"})
testMaker:addColumn({name = "col2", width = 20, textColor = "<green>"})
testMaker:addColumn({name = "col3", width = 30, textColor = "<purple>"})
testMaker:addRow({"row 1 col 1", "row 1 col 2", "row 1 col 3"})
testMaker:addRow({"row 2 col 1", "row 2 col 2", "row 2 col 3"})
testMaker:addRow({"row 3 col 1", "row 3 col 2", "row 3 col 3"})
cecho(testMaker:assemble())
I hope you're starting to see the kinds of things you can do with this, and how it may make formatting large amounts of items for display on your miniconsoles or main console a bit easier. For further information on the options available, please see fText: TableMaker