[Home] [Downloads] [Search] [Help/forum]

Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Copy ansi color from output as BBCode

Copy ansi color from output as BBCode

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

Posted by Khonsu   (5 posts)  [Biography] bio
Date Mon 08 Feb 2021 12:34 PM (UTC)
Hello. I want to start off by saying have almost no knowledge in Lua, or other languages really, and decided today to modify the ansi color copier to work for our forums and copy them as BBCode.

I have modified the copycolourcodes.xml and lotj_colours.lua to instead of copying &R &G etc to instead copy the codes with "[/color][color=#800000]" for the different colors. This works perfectly it seems. Edited out the line about added &w to the end since we don't need it for posting.

The problem I am running into, I think because of my limited knowledge on how to make this script, is that we will always have the [/color] at the very beginning of a line. This works great to end the color before a new color begins, but is there a simple way to have it remove the first [/color]?

For example:

&YYou sense a change in the &Glife &Yforces surrounding you.&w'&w


[/color][color=#FFFF00]You sense a change in the [/color][color=#00FF00]life [/color][color=#FFFF00]forces surrounding you.[/color][color=#C0C0C0]'
[Go to top] top

Posted by Nick Gammon   Australia  (22,966 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 08 Feb 2021 07:56 PM (UTC)
Can you please provide a link to where you found those files?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Khonsu   (5 posts)  [Biography] bio
Date Reply #2 on Mon 08 Feb 2021 09:41 PM (UTC)

Amended on Mon 08 Feb 2021 09:42 PM (UTC) by Khonsu

I was emailed the copycolourcodes by another player some time ago. Originally I think it comes from a post on this forum:


or perhaps


but may have been modified since then?

I uploaded the versions I have to


The ones with RP in the title are the ones I edited, probably poorly, to work with our Roleplay channels and Forum we upload to.
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] bio   Global Moderator
Date Reply #3 on Tue 09 Feb 2021 02:57 AM (UTC)

Amended on Tue 09 Feb 2021 03:07 AM (UTC) by Fiendish

The one you have came from me originally (for Aardwolf) and then it looks like someone modified it for a different game. The problem is that it's really built for a kind of system that only has color codes at the beginning, not ones that open/close on both sides of a text like you want.

There are also a bunch of things in the .lua file that definitely won't work that you don't need anyway (and so might benefit from just getting rid of).

I think instead of starting from the one you were given you should instead start from the one in http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=8821

No matter what, you're going to have to manually adjust the result to remove the [/color] at the front and add one to the end.

In Lua you can do that with something like (right before the line that says SetClipboard(copystring))

if copystring:sub(1,8) == "[/color]" then
   copystring = copystring:sub(9).."[/color]"

[Go to top] top

Posted by Khonsu   (5 posts)  [Biography] bio
Date Reply #4 on Wed 10 Feb 2021 12:36 AM (UTC)
Awesome that works perfectly.

I tried to use the one from the forum post you listed but I got some errors. I'll dig into it more later and see if I can get it work.

Thank you guys again.

If anyone wants a copy of these files I'll keep the drive link I posted earlier alive as long as that's OK.
[Go to top] 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.


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

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]