Feature Request: Client-side MXP coloring

Post Reply
User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Feature Request: Client-side MXP coloring

Post by tsuujin »

I would really like a method of compiling a string that includes color codes, to be output at one time (rather than changing the color previous to each echo command).

I do a lot of MUD UI tweaking, and i have several situations where I would like to be able to use functions to return partial string coloring rather than having to directly print to the screen. I think that this would most easily be achieved by allowing client-side mxp coloring tags (like I used to do with zmud), but if you have a better idea for implementation please let me know!

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Feature Request: Client-side MXP coloring

Post by tsuujin »

To be a bit more specific, here's an idea of one of the things I'd like to do:

Midkemia uses a breakdown of gold. 100 copper to a silver, 100 silver to a gold. I like to take in a copper number and output a colorized [gold.][silver.]copper string. This is fine if I just want to print it to the screen by itself, but I would really love to be able to actually have the function return a colorized string so the calling function can manipulate and print it seperately, or so that I could use the string as a replace() value. Right now I haven't found any way to do that.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Feature Request: Client-side MXP coloring

Post by Heiko »

The easiest way to do this - as I understand your problem - is to use named generic buffers. This is one of the features that aren't widely known, but which are very practical. The difference between buffers and a miniconsole is that buffers have no screen element, but apart from that they are identical i.e. you can use them to work with strings that carry format information such as color, bold, link etc.. When your processing is done, you simply copy the relevant line to the screen of your choice (miniconsole or main screen).

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Feature Request: Client-side MXP coloring

Post by Vadi »

Ahh... createBuffer(). Wonderful, I've been needing it myself as well.

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Feature Request: Client-side MXP coloring

Post by tsuujin »

Cool, this might work, but I'm having a bit of trouble getting it actually print to screen.

Think you could give me a quick example to create, print to and display a named buffer?

Also, perhaps, to append that buffer into a string if possible?

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Feature Request: Client-side MXP coloring

Post by Heiko »

There's a bug in the current pre-1 test release. It's fixed in pre-2 which will be available later. Here's some example code:

Code: Select all

createBuffer("buf")
--clearWindow("buf")
resetFormat("buf")
setFgColor("buf", 0,255,0)
echo("buf", "testbuf#1#green")
setFgColor("buf", 255,0,0)
echo("buf", "testbuf#1#red")
setBold("buf", true)
setUnderline("buf", true)
setFgColor("buf", 0,0,255)
echo("buf", "testbuf#1#blue,bold,underline\n")

moveCursor("buf",0,0)
selectCurrentLine("buf")
copy("buf")
appendBuffer()
for debug you can use this additional code that gets you the buffer as a popup window:

Code: Select all

moveWindow("buf",0,400)
resizeWindow("buf",600,400)
showWindow("buf")

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Feature Request: Client-side MXP coloring

Post by tsuujin »

Ah, the bug would explain why I couldn't get any output (confirmed by running your code verbatim with a failure on appendBuffer()).

Any idea when the pre2 comes out?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Feature Request: Client-side MXP coloring

Post by Vadi »

Tomorrow or soon after.

Post Reply