Search FAQ

Gammon Forum

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.
 Entire forum ➜ MUSHclient ➜ Plugins ➜ Prompt NewLine Plug-in

Prompt NewLine Plug-in

Posting of new messages is disabled at present.

Refresh page


Pages: 1 2  

Posted by Hanaisse   Canada  (114 posts)  Bio
Date Sun 22 Mar 2009 04:18 AM (UTC)

Amended on Sun 22 Mar 2009 04:19 AM (UTC) by Hanaisse

Message
I've been looking for this plug-in but can't find it in the plug-in list, so I searched these forums and found a very old thread that contained a 'simple version' (Nick's words) here;

http://www.gammon.com.au/forum/bbshowpost.php?id=7430

I copied it exactly into the plug-in wizard and installed but it's not acting in the way I expected.

I expected it to drop to a new line right after each prompt line like this;
<5000hp 5000m 4997mv>
You say 'hello'

Instead, I get, well, a space after the prompt like this;
<5000hp 5000m 4997mv> You say 'hello'

I have the latest version of MUSHclient installed with No Command Echo checked (because frankly command echo annoys me) on a SMAUG codebase.

Am I using the right plug-in for what I want? Is there a different one out there somewhere? Or perhaps I did something wrong?

aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 22 Mar 2009 04:25 AM (UTC)
Message
That fairly lengthy thread discusses various similar issues. For it to work the string.gsub in the plugin must match what your prompt looks like. I am not sure which one you used, but one of the ones I did matched a prompt with current and max values, which your prompt doesn't have.

In particular, this part:


function OnPluginPacketReceived (s)
return (string.gsub (s, "\n<.+/.+hp .+/.+m .+/.+mv .+/.+xp.*> ", "%1\n"))
end -- function OnPluginPacketReceived


Now your prompt would be matched by something like this:


function OnPluginPacketReceived (s)
return (string.gsub (s, "\n<%d+hp %d+m %d+mv> ", "%1\n"))
end -- function OnPluginPacketReceived



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hanaisse   Canada  (114 posts)  Bio
Date Reply #2 on Sun 22 Mar 2009 04:39 AM (UTC)
Message
Yes, I did replace the string.gsub with my prompt. Here is what it looks like.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, March 21, 2009, 11:42 PM -->
<!-- MuClient version 4.37 -->

<!-- Plugin "Add_NewLine_To_Prompt" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Add_NewLine_To_Prompt"
   author="Nick Gammon"
   id="3862dd7f2ba50abfe50d4844"
   language="Lua"
   purpose="Forces a newline after a prompt line"
   date_written="2009-03-21 23:38:18"
   requires="4.37"
   version="1.0"
   >

</plugin>


<!--  Script  -->


<script>
<![CDATA[
function OnPluginPacketReceived (s)
  return (string.gsub (s, "\n<&r%r &Y%h &C%m &G%v> ", "%1\n"))
end -- function OnPluginPacketReceived
]]>
</script>


</muclient>



I'm sorry, I don't understand what the %d means in your example or if it even pertains to this?

aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #3 on Sun 22 Mar 2009 05:38 AM (UTC)

Amended on Sun 22 Mar 2009 05:39 AM (UTC) by Onoitsu2

Message
%d is the Lua string representation of a digit, meaning a number, I, probably as well as Nick are perplexed by the &X's ... as well as the fact that the example prompt you posted has 3 sections, and this appears to be attempting to match 4 items.

-Onoitsu2
Top

Posted by Hanaisse   Canada  (114 posts)  Bio
Date Reply #4 on Sun 22 Mar 2009 06:44 AM (UTC)
Message
Er, oops. Bad example, there are 4 things in my prompt. The first %r displays room vnums. The other &thingies are colour codes. Even if I take them out I'm still not getting what I want.

10300 5000 5000 5000You say 'hello' is the output of this in the plugin...

function OnPluginPacketReceived (s)
  return (string.gsub (s, "\n<%r %h %m %v> ", "%1\n"))
end -- function OnPluginPacketReceived


aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #5 on Sun 22 Mar 2009 06:47 AM (UTC)
Message
The function in question is string.gsub:

http://www.gammon.com.au/scripts/doc.php?lua=string.gsub

That mentions that string.find explains Lua regular expressions:

http://www.gammon.com.au/scripts/doc.php?lua=string.find

Quote:

I, probably as well as Nick are perplexed by the &X


I think he has posted what he types into the MUD to get the prompt. Read up on regular expressions (see above link). The %d+ means one or more digits, which is what 5000 consists of. So %d+hp would match on some number of digits, followed by "hp". Try my example and see if it works.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #6 on Sun 22 Mar 2009 06:48 AM (UTC)
Message
Quote:

Even if I take them out I'm still not getting what I want.

10300 5000 5000 5000You say 'hello' is the output of this in the plugin...


Don't change the prompt, change the plugin to match the prompt.

You are changing the rules as we go, now there is a room number. However following the regular expression shown above you should be able to allow for that.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hanaisse   Canada  (114 posts)  Bio
Date Reply #7 on Sun 22 Mar 2009 08:46 PM (UTC)
Message
Quote:
I think he has posted what he types into the MUD to get the prompt.


lol, I was (btw, she not he).

Ok, I've read up on the regular expressions and it's becoming a little more clear. The string.gsub needs to match on the output, what the display window shows, right?

The output of my prompt is: <1000hp 1000m 750mv> <#21000>

And following your example it makes sense to have %d+hp to match on 1000hp, etc.

So I corrected the plugin to be this;

(string.gsub (s, "\n<%d+hp %d+m %d+mv %d> ", "%1\n")


(the extra %d on the end is for the room vnum in the prompt - not sure if that's correct or not)

Anyway, it still doesn't work. I'm not getting a new line.
<1000hp 1000m 750mv> <#21000> You say 'hello'


Note: I'm (obviously) not a coder so I really need a "Lua for Dummies" explanation.

aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #8 on Sun 22 Mar 2009 09:05 PM (UTC)
Message
Quote:

btw, she not he


My apologies. I normally type s/he but that day a wave of laziness overtook me. :)

Anyway, although you are getting closer, you put the room number in, in a way it wasn't going to match. I got it to work against your example prompt using:


function OnPluginPacketReceived (s)
  return (string.gsub (s, "\n<%d+hp %d+m %d+mv> <#%d+> ", "%1\n"))
end -- function OnPluginPacketReceived


Since the room number was in < ... > signs, the %d+ had to be inside them too.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hanaisse   Canada  (114 posts)  Bio
Date Reply #9 on Sun 22 Mar 2009 10:07 PM (UTC)
Message
Ok, I see what you did there. I copied that exactly into the plugin and it still doesn't work :(

aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #10 on Sun 22 Mar 2009 11:53 PM (UTC)
Message
Did you reinstall the plugin after changing it?

If so, please copy and paste the entire modified plugin. Also copy and paste a few sample lines from the MUD, so I can see the exact context in which the prompts appear?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hanaisse   Canada  (114 posts)  Bio
Date Reply #11 on Mon 23 Mar 2009 01:23 AM (UTC)
Message
Reinstalled, enabled, removed, added, saved the world, logged out, logged back in, tried everything.

Here's the plugin;

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, March 22, 2009, 11:52 AM -->
<!-- MuClient version 4.37 -->

<!-- Plugin "NewLine" generated by Plugin Wizard -->

<muclient>
<plugin
   name="NewLine"
   author="Nick Gammon"
   id="1baba0fed265b8662b599a8f"
   language="Lua"
   purpose="Forces a newline after a prompt line"
   date_written="2009-03-22 11:50:02"
   requires="4.37"
   version="1.0"
   >

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Script  -->

<script>
<![CDATA[
function OnPluginPacketReceived (s)
  return (string.gsub (s, "\n<%d+hp %d+m %d+mv> <#%d+> ", "%1\n"))
end -- function OnPluginPacketReceived
]]>
</script>


</muclient>


And some samples of what I'm looking at;

<1000hp 1000m 742mv> <#21020> Inside the Southern Gate
You stand inside the southern gate of Darkhaven.  To the north is the
intersection of Vertic Avenue and Law Avenue.
Exits: north.
A guard of the city stands at the ready.

<1000hp 1000m 750mv> <#21074> You are carrying:
     Nothing.

<1000hp 1000m 750mv> <#21074> You say 'hello'

<1000hp 1000m 750mv> <#21074> 
The bells of the cathedral toll the passing of time.


Funny how the area reset message starts on a new line but that does that already without the plugin.

aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000
Top

Posted by Onoitsu2   USA  (248 posts)  Bio
Date Reply #12 on Mon 23 Mar 2009 01:54 AM (UTC)
Message
Are there color codes involved, that is the only reason, I think that this might not be functioning properly is if there are multiple colors in the code, and it is not matching against the escape codes for the colors.

I had the same issue with several packet matches.

-Onoitsu2
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #13 on Mon 23 Mar 2009 02:44 AM (UTC)
Message
I think we need to see the raw packets - Onoitsu2 is right, colour codes would throw things out because we are matching the raw data.

Go to the Edit menu -> Debug Packets (check it).

Then grab a few prompts. Then turn Debug Packets off again or the packet debug window will get very large.

Then paste the results here, please.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hanaisse   Canada  (114 posts)  Bio
Date Reply #14 on Mon 23 Mar 2009 03:22 AM (UTC)
Message
Yes the prompt is coloured. It's the default in SmaugFUSS, I haven't changed it.
But now I'm totally confused as to how matching the prompt as it's seen is messed up by colour code that's not seen.

Hopefully you'll find the problem in here;

Sent  packet: 177 (5 bytes) at Sunday, March 22, 2009, 11:16:56 PM

inv..              69 6e 76 0d 0a

Incoming packet: 349 (123 bytes) at Sunday, March 22, 2009, 11:16:56 PM

.[1;31mYou are c   1b 5b 31 3b 33 31 6d 59 6f 75 20 61 72 65 20 63
arrying:..     .   61 72 72 79 69 6e 67 3a 0d 0a 20 20 20 20 20 1b
[1;32mNothing...   5b 31 3b 33 32 6d 4e 6f 74 68 69 6e 67 2e 0d 0a
...[0m.[0;37m<.[   0d 0a 1b 5b 30 6d 1b 5b 30 3b 33 37 6d 3c 1b 5b
1;33m1000hp .[1;   31 3b 33 33 6d 31 30 30 30 68 70 20 1b 5b 31 3b
36m1000m .[1;32m   33 36 6d 31 30 30 30 6d 20 1b 5b 31 3b 33 32 6d
748mv.[0;37m> <#   37 34 38 6d 76 1b 5b 30 3b 33 37 6d 3e 20 3c 23
21074> .[0m        32 31 30 37 34 3e 20 1b 5b 30 6d

Sent  packet: 178 (11 bytes) at Sunday, March 22, 2009, 11:17:07 PM

say hello..        73 61 79 20 68 65 6c 6c 6f 0d 0a

Incoming packet: 350 (99 bytes) at Sunday, March 22, 2009, 11:17:07 PM

.[1;36mYou say '   1b 5b 31 3b 33 36 6d 59 6f 75 20 73 61 79 20 27
hello'.....[0m.[   68 65 6c 6c 6f 27 0d 0a 0d 0a 1b 5b 30 6d 1b 5b
0;37m<.[1;33m100   30 3b 33 37 6d 3c 1b 5b 31 3b 33 33 6d 31 30 30
0hp .[1;36m1000m   30 68 70 20 1b 5b 31 3b 33 36 6d 31 30 30 30 6d
 .[1;32m748mv.[0   20 1b 5b 31 3b 33 32 6d 37 34 38 6d 76 1b 5b 30
;37m> <#21074> .   3b 33 37 6d 3e 20 3c 23 32 31 30 37 34 3e 20 1b
[0m                5b 30 6d


aka: Hana
Owner in Training of: Fury of the Gods
alm-dev.org:4000
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.


69,602 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

Posting of new messages is disabled at present.

Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.