Ok.. I know I have gone over this before and you have said that Mushclient was never intended to allow this sort of thing. However, I recently realized that it would be convenient to add a real hyperlink to something for those that have MXP, but to use it with Mushclient requires 'faking' the way other client mishandle other 'bad' tags. So here is what I came up with this time:
function MXP_Error (level, number, line, message)
dim StyleF, StyleB
if level = "E" and number = 1001 then
Inf = GetLineInfo(line, 11)
StyleF = GetStyleInfo(line, 1, 14)
StyleB = GetStyleInfo(line, 1, 15)
colourtell RGBColourToName(StyleF), RGBColourToName(StyleB), "<"
end if
if level = "A" and number = 20000 then
setvariable "LastElement", message
dim Inf, t
Inf = GetLineInfo(line, 11)
StyleF = GetStyleInfo(line, 1, 14)
StyleB = GetStyleInfo(line, 1, 15)
setvariable "LEFore",StyleF
setvariable "LEBack",StyleB
end if
if level = "E" and number = 1023 then
StyleF = getvariable("LEFore")
StyleB = getvariable("LEBack")
colourtell RGBColourToName(StyleF), RGBColourToName(StyleB), replace(getvariable("LastElement"),"MXP element: ","")
end if
MXP_Error = 1
end function
It works like a charm, save for two issues. Example: if I send these lines>
<color purple>Loriah << East Road - Bladesman Avenue >>
<color gold>Loriah << East Road - Bladesman Avenue >>
You get:
-purple-Loriah
-previous color-<< East Road - Bladesman Avenue >>
-gold-Loriah
-purple-<< East Road - Bladesman Avenue >>
So.. Problem one - When an MXP error happens, it automatically adds a life feed. This only happens if you are using the Error callback. Why?? It makes no sense for this to happen, especially since the rest of the line appears 'after' anything you do in the function. I.e.
With MXP Error:
Loriah
>
Without it:
Loriah >
Second issue, the line number that the error 'supposedly' happened on is either wrong or something is not being processed right, because the line styles for that line do not match what exists there. Instead it seems to be retrieving line styles from the 'previous' line. However the actually line contents when returned using GetlineInfo(line,1) is correct. Worse, Inf in the above shows 3 styles on the line, but style 2 is invalid (NULL strings) and causes the colourtell in the if-then with 1023 to generate an error.
Neither of these problems make sense imho. Though the later 'could' be the result of the line not yet completing, since the last ">" has yet to be displayed, but then why would it be returning a style at all, even if inherited from the prior line?
NOTE: While in my case I am trying to cheat my way around the way Mushclient handles things, there have been cases in the past where something like this would have been helpful for those who just plain happened to play on a mud where MXP isn't implimented properly. Due to these two quirks, there is simply way around the problem, especially since there is also no option for colourtell that will make it default to the 'current color', but instead it seems to default to the note color. :p This could be a nice addition:
colournote "current_color","current_background","Blah.."
colourtell "current_color","current_background","Blah.."
It would at least solve one problem and could be fairly useful, since it would let you insert lines into something that match the color, without relying on Styles, which often prove to be a major pain when all you want to do is get the current colors being displayed. |