Right, just changing it to be suffix instead of echo will print everything in the opposite order, same with prefix. It would really be nice if the echoing (prefix, echo, suffix, insertText) would all support this notation.
I did find a bug, however. If I have a > or a < in the text, the function will filter it out and not print it. I tried escaping it in different ways, but that wouldn't work. Suggestions?
Echo with color.
Re: Echo with color.
I added escaping with \ to the lrexlib versions. It'll be available in the next release. Note that you'll need to do either cecho("\\<red>") or cecho([[\<red>]]) as \ is an escape character in Lua as well.
Iocun, I have modified versions of your native Lua functions included as fallbacks if lrexlib isn't found, if you want to modify them so they can be escaped, I'll include that.
Iocun, I have modified versions of your native Lua functions included as fallbacks if lrexlib isn't found, if you want to modify them so they can be escaped, I'll include that.
Re: Echo with color.
Thank you for your hard work, looking forward to next release!
As for prefixing using moveCursor and insertText, whenever I use that on a string like this:
it will show up like this when output to the game (using moveCursor to the start of the line first):
]SomeText[
It seems like insertText does not move the cursor but rather keeps it at the position mentioned. I suppose I could move the cursor forward as I'm adding text, unless there is another way.. Suggestions?
As for prefixing using moveCursor and insertText, whenever I use that on a string like this:
Code: Select all
"<red>[<green>Some Text<red>]"
]SomeText[
It seems like insertText does not move the cursor but rather keeps it at the position mentioned. I suppose I could move the cursor forward as I'm adding text, unless there is another way.. Suggestions?
Re: Echo with color.
If I understand your problem correctly, try:
Code: Select all
moveCursor("main", 0, getLineCount()-1)
cecho("<red>[<green>Text<red>]", nil, nil, true)
moveCursorEnd("main")
Re: Echo with color.
Ok, going to give this a try and see if it works when I get back from work today. It should work fine to just overwrite the prefix function into something like this:
Thanks for all help
Code: Select all
function prefix(what, color)
if color == true then
moveCursor("main", 0, getLineCount()-1)
cecho("<red>[<green>Text<red>]", nil, nil, true)
moveCursorEnd("main")
else
moveCursor("main",0,getLineNumber());
insertText(what)
end
end
Re: Echo with color.
Oh, nevermind.
Prefix just moves the cursor to the beginning of the current line it's on, by default the last line received, and inserts the text there. If you want to return the cursor to its normal position afterwards, use moveCursorEnd. I'll look into making it possible to use color with prefix and suffix. Until then you can emulate the behavior with: moveCursor("main",0,getLineNumber()); cecho("whatever", nil, nil, true)
Setting the fourth argument of cecho to true makes it use inserttext instead of echo.
Prefix just moves the cursor to the beginning of the current line it's on, by default the last line received, and inserts the text there. If you want to return the cursor to its normal position afterwards, use moveCursorEnd. I'll look into making it possible to use color with prefix and suffix. Until then you can emulate the behavior with: moveCursor("main",0,getLineNumber()); cecho("whatever", nil, nil, true)
Setting the fourth argument of cecho to true makes it use inserttext instead of echo.
Re: Echo with color.
Found another little bug for you to look at. Look at this:
|c00FF00Target: |cFF0000Bandit
It should output Target: Bandit
but it actually outputs: Target: ndit
In your rex split about halfway through the function, you do ",?" to check if there is a comma, but in theory that only checks if the comma is there, but keeps processing if there's more text after it. It would mean one could write |cff000000ff00 to make red text on green background.
It can be fixed by adding a space after the color group, but you're not always able to do that. Can we get a terminating character for the clause or so?
Also, I'd really like to see the possibility to use <color name> in there somehow just like in the function listed earlier in this thread? It really does look better having "<yellow>Target: <red>Bandit" instead of all the hex code Perhaps a flag to cecho to use color names or hex?
|c00FF00Target: |cFF0000Bandit
It should output Target: Bandit
but it actually outputs: Target: ndit
In your rex split about halfway through the function, you do ",?" to check if there is a comma, but in theory that only checks if the comma is there, but keeps processing if there's more text after it. It would mean one could write |cff000000ff00 to make red text on green background.
It can be fixed by adding a space after the color group, but you're not always able to do that. Can we get a terminating character for the clause or so?
Also, I'd really like to see the possibility to use <color name> in there somehow just like in the function listed earlier in this thread? It really does look better having "<yellow>Target: <red>Bandit" instead of all the hex code Perhaps a flag to cecho to use color names or hex?
Re: Echo with color.
The problem in the hex function should already be fixed in my local copy. A lot has changed since the last release.
We're splitting it into three separate functions, cecho, hecho and decho. cecho uses <color>, hecho uses |cXXXXXX, and decho uses <nnn,nnn,nnn>
We're splitting it into three separate functions, cecho, hecho and decho. cecho uses <color>, hecho uses |cXXXXXX, and decho uses <nnn,nnn,nnn>
Re: Echo with color.
Ahhhh, I see. Any plan on when your local version is going to be released?
Re: Echo with color.
Whenever the next Mudlet release is, I'd have to ask Heiko.