Hyperlink and ColourNote

Posted by AdInfinitum on Tue 07 Aug 2018 07:20 PM — 3 posts, 14,678 views.

#0
Currently, I have a script to return a table of information from an equipment database, returning lines like:


My awesome sword         1       123456


The way I set it up is by iterating through db:rows() and using table.insert in the following manner:


for a in eqdb:rows() do
    local eqname, eqlvl, eqid = a[1], a[2], a[3]
    results = {"green", "", eqname .. string.rep(" ", 20-#eqname), "yellow", "", eqlvl .. string.rep(" ", 5-#tostring("eqlvl"), "magenta", "", eqid}
end

for _,v in ipairs(results) do
    ColourNote(unpack(v))
end


And it works perfectly. However, now I'm finding that I want to add a hyperlink to the third column, the eqid, and I'm unsure how to do that. To be clear, I want only the id to be hyperlinked, not the entire row.

Is there a way I can possibly do this? What will I have to rewrite, or how should I rewrite it, to get it to do what I want?

Thank you, as always!
Australia Forum Administrator #1
You would need to rework it a bit. For the non-hyperlink entries use ColourTell (which does not start a new line). For the hyperlink entry use Hyperlink. Then finish of the line with "print()" to force a new line.
#2
I thought that might be the case.

I wound up rewriting the code, so it works now. The biggest problem I faced was checking for failure, since "a" always existed. It didn't occur to me to check if "a" was "" or not, though.

Thanks for the feedback. I wasn't sure if there were a way I could just group it all into a table and expand it that way, but this works fabulously.