Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Hyperlink and ColourNote

Hyperlink and ColourNote

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by AdInfinitum   (74 posts)  Bio
Date Tue 07 Aug 2018 07:20 PM (UTC)
Message
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!
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 07 Aug 2018 08:30 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by AdInfinitum   (74 posts)  Bio
Date Reply #2 on Tue 07 Aug 2018 10:42 PM (UTC)
Message
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.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,526 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.