Phrase Color Triggering for #00FF00 within Miniconsole

Share your scripts and packages with other Mudlet users.
Post Reply
Yunalesca
Posts: 6
Joined: Thu Jan 27, 2022 7:07 am

Phrase Color Triggering for #00FF00 within Miniconsole

Post by Yunalesca »

Hi, if anyone could help with parsing certain phrases with #00FF00 color within the miniconsole and turn it into another color, that would be very very helpful.

I attached a image. I would like the green text to be a different color (this is for the miniconsole not the main window).
Attachments
Screen Shot 2022-01-27 at 2.12.20 AM.png

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Phrase Color Triggering for #00FF00 within Miniconsole

Post by demonnic »

How is the text getting to the miniconsole?

Yunalesca
Posts: 6
Joined: Thu Jan 27, 2022 7:07 am

Re: Phrase Color Triggering for #00FF00 within Miniconsole

Post by Yunalesca »

I attached another screenshot. The text inside the quotes in black are the contents of the text sent to the miniconsole.

The script uses these commands below (not sure if there is more connected) to get and send text to miniconsole:

local comm_data = gmcp.comm.channel
local replaced = ansi2decho(comm_data.msg)
display(comm_data.msg)

local chan = gmcp.comm.channel.chan
if (chan == "All") then
decho("All",replaced .. "\n")--send a copy to "All" tab
end
Attachments
Screen Shot 2022-01-27 at 12.19.33 PM.png

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Phrase Color Triggering for #00FF00 within Miniconsole

Post by demonnic »

You could accomplish this by doing
Code: [show] | [select all] lua
replaced = string.gsub(replaced, "<0,255,0>", "<255,0,0>")
to change it from the green to red for instance. you'll need to use the r,g,b decimal format since it's using ansi2decho and decho. And you'd want to do it ahead of the decho.

Yunalesca
Posts: 6
Joined: Thu Jan 27, 2022 7:07 am

Re: Phrase Color Triggering for #00FF00 within Miniconsole

Post by Yunalesca »

Thank you so much! It works perfectly!

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Phrase Color Triggering for #00FF00 within Miniconsole

Post by demonnic »

Glad I could help =)

Post Reply