Hey all, have a problem. I have a nice miniwindow made, just a basic 200x200 window, I can print a minimap to it via an MSDP variable sent by the mud. However I cannot get the ansi colors to show. I can handle the newlines just fine, but not the colors. Right now I break the map into lines using new lines as a delimiter, which gives me a nice table for the map. Anyone know how I can parse this table and display the colors without using a trigger or OnPluginPacketReceived()? not sure how I can use those with MSDP.
reading color from an MSDP variable and printing to a miniwindow
Posted by Ewave on Sun 01 Feb 2015 03:06 AM — 7 posts, 26,590 views.
Quote:
Right now I break the map into lines using new lines as a delimiter, which gives me a nice table for the map. Anyone know how I can parse this table and display the colors without using a trigger or OnPluginPacketReceived()? not sure how I can use those with MSDP.
Right now I break the map into lines using new lines as a delimiter, which gives me a nice table for the map. Anyone know how I can parse this table and display the colors without using a trigger or OnPluginPacketReceived()? not sure how I can use those with MSDP.
Perhaps if you disclose what this table contains we can help you more.
You should be able to simply trigger in the color codes themselves, though that will probably need some OnPacket functionality to be involved for best results. MSDP doesn't directly supply color according to the specs I'm familiar with so there's not going to be a simple check on the msdp info but the color codes should be easy enough to grab and manipulate the map with.
As for doing it without using a trigger or OnPluginPacket, not so sure that's going to be possible (it certainly isn't with my skills) but maybe Nick can work a miracle for you.
As for doing it without using a trigger or OnPluginPacket, not so sure that's going to be possible (it certainly isn't with my skills) but maybe Nick can work a miracle for you.
Thanks for the replies :) Here is the table:
As you can see it's just strings with ansi colors in them. Right now I'm printing them to the mini window line by line, which works pretty well. If I could get the style runs from them, I'd be able to do it, but that seems to be an impossible task so far? (EDIT: also the map is spaced properly, but not in this forum post)
[EDIT] Code tags added.
1="`2 `7*`7-`7+`7-`7* "
2=" `8| "
3=" `3S`8-`8+`7-`3S "
4=" `8| "
5=" `3S`8-`!@`7-`7*`2 "
6=" `8| "
7="`3S `3S`8-`8+`7-`3S "
8="`8| `7| "
9="`8+`8-`8+`7-`&+`8-`8+`8-`8+`7``"
10=""
As you can see it's just strings with ansi colors in them. Right now I'm printing them to the mini window line by line, which works pretty well. If I could get the style runs from them, I'd be able to do it, but that seems to be an impossible task so far? (EDIT: also the map is spaced properly, but not in this forum post)
[EDIT] Code tags added.
Put it in a code block to preserve formatting in your post.
Which is the color code in those runs?
Which is the color code in those runs?
the '1-9 + other symbols. E.G. `! is bold red.
Simple enough. Add a default colour to the start of lines (in case they don't start with a colour) and then do a string.gmatch to pull out colour sequences and text. For example:
Results:
Now of course you don't "print" the stuff, you do a WindowText with the text and the colour code (some sort of lookup table).
To prove we are extracting the map OK, I'll just print the text and ignore the colour:
Result:
t = {
[1]="`2 `7*`7-`7+`7-`7* ",
[2]=" `8| ",
[3]=" `3S`8-`8+`7-`3S ",
[4]=" `8| ",
[5]=" `3S`8-`!@`7-`7*`2 ",
[6]=" `8| ",
[7]="`3S `3S`8-`8+`7-`3S ",
[8]="`8| `7| ",
[9]="`8+`8-`8+`7-`&+`8-`8+`8-`8+`7``",
[10]="",
}
for _, line in ipairs (t) do
-- ensure line starts with default colour
line = '`0' .. line
for colour, text in string.gmatch (line, "`(%d)([^`]+)") do
print ("Colour =", colour)
print ("Text = <" .. text .. ">")
end -- for each style run
print ""
end -- for
Results:
Colour = 2
Text = < >
Colour = 7
Text = <*>
Colour = 7
Text = <->
Colour = 7
Text = <+>
Colour = 7
Text = <->
Colour = 7
Text = <* >
Colour = 0
Text = < >
Colour = 8
Text = <| >
Colour = 0
Text = < >
Colour = 3
Text = <S>
Colour = 8
Text = <->
Colour = 8
Text = <+>
Colour = 7
Text = <->
Colour = 3
Text = <S >
Colour = 0
Text = < >
Colour = 8
Text = <| >
Colour = 0
Text = < >
Colour = 3
Text = <S>
Colour = 8
Text = <->
Colour = 7
Text = <->
Colour = 7
Text = <*>
Colour = 2
Text = < >
Colour = 0
Text = < >
Colour = 8
Text = <| >
Colour = 3
Text = <S >
Colour = 3
Text = <S>
Colour = 8
Text = <->
Colour = 8
Text = <+>
Colour = 7
Text = <->
Colour = 3
Text = <S >
Colour = 8
Text = <| >
Colour = 7
Text = <| >
Colour = 8
Text = <+>
Colour = 8
Text = <->
Colour = 8
Text = <+>
Colour = 7
Text = <->
Colour = 8
Text = <->
Colour = 8
Text = <+>
Colour = 8
Text = <->
Colour = 8
Text = <+>
Colour = 2
Text = < >
Colour = 7
Text = <*>
Colour = 7
Text = <->
Colour = 7
Text = <+>
Colour = 7
Text = <->
Colour = 7
Text = <* >
Colour = 0
Text = < >
Colour = 8
Text = <| >
Colour = 0
Text = < >
Colour = 3
Text = <S>
Colour = 8
Text = <->
Colour = 8
Text = <+>
Colour = 7
Text = <->
Colour = 3
Text = <S >
Colour = 0
Text = < >
Colour = 8
Text = <| >
Colour = 0
Text = < >
Colour = 3
Text = <S>
Colour = 8
Text = <->
Colour = 7
Text = <->
Colour = 7
Text = <*>
Colour = 2
Text = < >
Colour = 0
Text = < >
Colour = 8
Text = <| >
Colour = 3
Text = <S >
Colour = 3
Text = <S>
Colour = 8
Text = <->
Colour = 8
Text = <+>
Colour = 7
Text = <->
Colour = 3
Text = <S >
Colour = 8
Text = <| >
Colour = 7
Text = <| >
Colour = 8
Text = <+>
Colour = 8
Text = <->
Colour = 8
Text = <+>
Colour = 7
Text = <->
Colour = 8
Text = <->
Colour = 8
Text = <+>
Colour = 8
Text = <->
Colour = 8
Text = <+>
Now of course you don't "print" the stuff, you do a WindowText with the text and the colour code (some sort of lookup table).
To prove we are extracting the map OK, I'll just print the text and ignore the colour:
for _, line in ipairs (t) do
-- ensure line starts with default colour
line = '`0' .. line
for colour, text in string.gmatch (line, "`(%d)([^`]+)") do
Tell (text)
end -- for each style run
print ""
end -- for
Result:
*-+-*
|
S-+-S
|
S--*
|
S S-+-S
| |
+-+--+-+