Thanks! Works great. Seems I could have find the answer myself if looking after it harder ... I'm getting better at it tho.
I have another newb question tho, related to an old post:
http://www.gammon.com.au/forum/?id=7430
In the mud I'm in now (Toril) the prompt can have mainly 2 forms:
"< 183h/183H 236p/236P 120v/120V P: std > "
"< 252h/179H 229p/229P 120v/120V T: Ginewe TC: few scratches E: bugbear EC: few wounds P: std > "
And there also can be an " (AFK) " tag at the end.
The regexp I came up with:
^\< (?P<hp>\d+)h\/(?P<maxhp>\d+)H (?P<psp>\d+)p\/(?P<maxpsp>\d+)P (?P<mv>\d+)v\/(?P<maxmv>\d+)V (?:T\: (?P<tn>[a-zA-Z ]+) TC\: (?P<tc>[a-zA-Z ]+) E\: (?P<en>[a-zA-Z ]+) EC\: (?P<ec>[a-zA-Z ]+) )?P\: (?P<pos>\w{3}) (?:\(AFK\) )?\> $
I got my plugin to work, but it was always one "tick" too late, as you probably guessed already problem is the mud doesn't send a newline after displaying the current status.
So I looked in the forum for a similar problem and saw the post mentioned before and guessed it could solve my problem (I'm still not sure).
So had to "translate" the regexp to fit (only a simple version so far, outside fight) and here are the lines I tried:
"\n< .+h/.+H .+p/.+P .+v/.+V P: ... > "
"\n< .+h/.+H .+p/.+P .+v/.+V P: .+ > "
However I can't get it to work properly (it get installed but doesn't do anything) ... To tell the truth I'm not even sure I understand how it is supposed to work. Here is the modified code:
---------------------------------------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, October 22, 2006, 7:40 AM -->
<!-- MuClient version 3.82 -->
<!-- Plugin "Add_NewLine_To_Prompt" generated by Plugin Wizard -->
<muclient>
<plugin
name="Add_NewLine_To_Prompt"
author="Nick Gammon"
id="1f68b8da856ceccb6f2ea308"
language="Lua"
purpose="Forces a newline after a prompt line"
date_written="2006-10-22 07:38:36"
requires="3.82"
version="1.0"
>
</plugin>
<!-- Script -->
<script>
<![CDATA[
function OnPluginPacketReceived (s)
return (string.gsub (s, "\n< .+h/.+H .+p/.+P .+v/.+V P: .+ > ", "%1\n"))
end -- function OnPluginPacketReceived
]]>
</script>
</muclient>