-
Notifications
You must be signed in to change notification settings - Fork 9
fText: TableMaker: Examples: Clickable Tables
Damian Monogue edited this page Feb 7, 2021
·
1 revision
A short video showing the clickable cells. The code below is taken from this example.
YouTube Presentation
This next bit of code makes a MiniConsole to hold the table. We set autoClear and allowPopups so that we can add popup cells. Setting allowPopups automatically sets autoClear as well. It will also display the assembled table at the end.
-- make the container to hold things in
testCon = testCon or Geyser.MiniConsole:new({ x = 100, width = "69c", height = "9c"})
testCon:setFontSize(12)
testCon:resize("69c", "9c")
local TableMaker = require("MDK.ftext").TableMaker
testMaker3 = TableMaker:new({
autoClear = true,
allowPopups = true,
})
testMaker3:setAutoEchoConsole(testCon)
testMaker3:addColumn({name = "col1", width = 15, textColor = "<orange>"})
testMaker3:addColumn({name = "col2", width = 20, textColor = "<green>"})
testMaker3:addColumn({name = "col3", width = 30, textColor = "<purple>"})
testMaker3:addRow({"row 1 col 1", "row 1 col 2", "row 1 col 3"})
testMaker3:addRow({"row 2 col 1", "row 2 col 2", "row 2 col 3"})
testMaker3:addRow({"row 3 col 1", "row 3 col 2", "row 3 col 3"})
testMaker3:assemble()
To create a clickable cell, pass a table of parameters for either echoLink or echoPopup. It will detect which one to use based on whether the second parameter is a table or not. If it's a table then it assumes it is echoPopup, if it's a string it will use echoLink.
testMaker3:setCell(1,1,{"Siddown", [[send("sit")]], "siddown!", false})
testMaker3:setCell(2,3,{"r2c3", {[[send("sit")]], [[send("stand")]]}, {"siddown!", "standup!"}})