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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Capturing prompt with colours
Capturing prompt with colours
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Indoum
Sweden (17 posts) Bio
|
Date
| Fri 26 May 2006 09:30 PM (UTC) |
Message
| Using OnPluginPartialLine(), I capture the values of my prompt and it's working just fine. Now I'm pondering the posibility to capture the full prompt, with ANSI and all, to echo it out later on. How can I do this? | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #1 on Sat 27 May 2006 02:31 AM (UTC) |
Message
| With Lua you can use a trigger and the script function it calls will receive a fourth argument, containing all the ANSI styles for the prompt. Or you can use OnPluginPartialLine, which you already use. How to do it really depends on what exactly you want to do with the styles and the prompt. | Top |
|
Posted by
| Indoum
Sweden (17 posts) Bio
|
Date
| Reply #2 on Sat 27 May 2006 11:03 AM (UTC) |
Message
| As I said, I want to capture it to echo out an copy of it later on.
I'd really appreciate it if you could show me some example code on how I could capture the ANSI code from using OnPluginPartialLine() and then print out a copy. Thanks! | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #3 on Sat 27 May 2006 07:46 PM (UTC) Amended on Sat 27 May 2006 09:27 PM (UTC) by Ked
|
Message
| For simply echoing the prompt "as is", without any modifications, a trigger and a Lua script would probably fit you best. OnPluginPartialLine is useful mainly when you need to know the exact ANSI codes and their positions in the line. Styles, as seen from Lua, just give you a table of "style runs", which correspond to what you would see on the screen, but don't necessarily precisely coincide with what was actually in the recieved packet.
I haven't really used styles that much, so you'd need to experiment with them a bit, but it's simple enough. From what I remember, the table stores pieces of text from the captured line and corresponding styling info for each piece - colour and whether it's bold, italic, underlined. So to echo a prompt, you'd create a trigger to match on it, and make it call a Lua script like:
prompts = {}
function saveTrigger(name, output, wildcs, styles)
table.insert(prompts, styles)
end
That will save your prompts, as represented by their styles information, in a global table, with the most recent prompt placed at the end of that table. Later you could display the last prompt, removing it from the table:
function echoLastPrompt()
prompt = table.remove(prompts)
-- if prompt is nil then we are out of prompts to
-- display for now
if prompt == nil then
return
end
-- iterate over the styles in the prompt
for chunk,style in prompt do
local text = style.text
local fore = RGBColourToName(style.textcolour)
local back = RGBColourToName(style.backcolour)
ColourTell(fore, back, text)
end
Tell("\n") -- terminate the prompt with a newline
end
Hope that helps.
| 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.
15,813 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top