Add_Newline_To_Prompt Plugin

Posted by Mike.mac.kenzie on Sat 02 Dec 2023 09:08 AM — 13 posts, 25,082 views.

#0
Hello there MUSHclient users.

I'm currently working on an autosipper, but I have prompt issue where it does not sip automatically and requires me to hit enter or requires another line to happen in the game before the trigger actually fires. I found a plugin that should solve this issue, it's called Add_Newlie_To_Prompt and is supposed to force the autosipper to fire properly by basically faking a newline on prompt

The problem I am having is that when I use the plugin and enable it, my prompt completely disappears. Can anyone help me figure out what I may be doing wrong here?
Australia Forum Administrator #1
Can you give a link to the exact plugin you used?
#2
https://gammon.com.au/forum/bbshowpost.php?bbsubject_id=5020

There is the link that I got the plugin from.
Australia Forum Administrator #3
There is more than one plugin in that thread. Can you give the "id" of the one you are using? Or just copy/paste it here?

Have you read all of that thread? It appears to be about autosippers.
#4
Here is the plugin I used. It appears to be the top plugin posted on the page I posted the URL for. It is definitely about autosippers. I am trying to get my own autosipper working, but it does not fire properly on the prompt. I have to enter a newline after the prompt manually, to get it to fire.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient[
  <!ENTITY prompt_regexp "^\\x1B\\[0m&lt;.+hp .+m .+mv .+xp&gt; $" > 
]>
<!-- MuClient version 3.59 -->

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

<muclient>
<plugin
   name="Add_Newline_To_Prompt"
   author="Nick Gammon"
   id="8316c19c35a9ebdb46055874"
   language="Lua"
   purpose="Adds a newline to prompt lines"
   date_written="2004-12-13 12:08:00"
   requires="3.59"
   version="1.0"
   >
<description trim="y">
Detects prompt lines without a newline, and if found, adds one.

Change ENTITY line on 3rd line of plugin to be a regular expression 
that matches your prompt.

</description>

</plugin>

<!--  Script  -->

<script>

  re = rex.new ("&prompt_regexp;")

<![CDATA[

partial = ""  -- partial line from last time through

function OnPluginPacketReceived (s)

  -- add packet to what we already have (excluding carriage-returns)
  
  partial = partial .. string.gsub (s, "\r", "")
  
  t = {}  -- table of lines to be returned
  
  -- iterate over each line
  
  partial = string.gsub (partial, "(.-)\n", 
    function (line) 
     table.insert (t, line) 
     return "" -- added for MUSHclient 3.80+
    end)
  
  -- look for prompt

  if (re:match (partial)) then
    table.insert (t, partial)
    partial = ""
  end -- if found prompt

  if table.getn (t) > 0 then
    table.insert (t, "")  -- to get final linefeed
  end -- if
    
  -- return table of lines, concatenated with newlines between each one
  return table.concat (t, "\n")
  
end -- function OnPluginPacketReceived
]]>
</script>

</muclient>
Amended on Sun 10 Dec 2023 06:57 AM by Nick Gammon
Australia Forum Administrator #5
OK, now what we need you to do is show your exact prompt. Copy/paste from some MUD output into a reply.
Australia Forum Administrator #6
Meanwhile, you could try the second plugin on that page.
#7
My prompt has 3 options.

920/920h 115/115m >
920/920h 115/115m u>
920/920h 115/115m f>

Here is what I was using for regexp version of my prompt, within the plugin.

^(.*?)\/(.*?)h (.*?)\/(.*?)m(.*?)\>$

I also tried the "small fix" where you posted to copy and paste the following over the old version of the same part of the code.

partial = string.gsub (partial, "(.-)\n",
function (line)
table.insert (t, line)
return ""
end)

I also tried the second simpler version of the plugin but it did not work.
USA Global Moderator #8
"\/" and "\>" are not valid pattern components because / and > do not need to be escaped.
Australia Forum Administrator #9
When matching incoming packets, the match text has to be exact, including any ANSI colour codes that might be there. To find what they are, we need to see an exact packet.

To do that, go to the Edit menu -> Debug Packets, and then grab a couple of prompts. Turn off Debug Packets afterwards.

Another window will open with the packet information in hex.

Copy/paste that into a reply. Thank you.
#10

Incoming packet: 4642 (2 bytes) at Saturday, December 23, 2023, 9:10:00 AM

..                 0d 0a

Incoming packet: 4643 (77 bytes) at Saturday, December 23, 2023, 9:10:00 AM

You snore and tu   59 6f 75 20 73 6e 6f 72 65 20 61 6e 64 20 74 75
rn in your sleep   72 6e 20 69 6e 20 79 6f 75 72 20 73 6c 65 65 70
....[0;0m3560.[0   2e 0d 0a 1b 5b 30 3b 30 6d 33 35 36 30 1b 5b 30
;0m/3560h 445.[0   3b 30 6d 2f 33 35 36 30 68 20 34 34 35 1b 5b 30
;0m/445m > ÿù      3b 30 6d 2f 34 34 35 6d 20 3e 20 ff f9

Sent  packet: 3591 (5 bytes) at Saturday, December 23, 2023, 9:10:05 AM

who..              77 68 6f 0d 0a

Incoming packet: 4644 (20 bytes) at Saturday, December 23, 2023, 9:10:05 AM

You are fast asl   59 6f 75 20 61 72 65 20 66 61 73 74 20 61 73 6c
eep.               65 65 70 2e

Incoming packet: 4645 (44 bytes) at Saturday, December 23, 2023, 9:10:05 AM

...[0;0m3560.[0;   0d 0a 1b 5b 30 3b 30 6d 33 35 36 30 1b 5b 30 3b
0m/3560h 445.[0;   30 6d 2f 33 35 36 30 68 20 34 34 35 1b 5b 30 3b
0m/445m > ÿù       30 6d 2f 34 34 35 6d 20 3e 20 ff f9

Sent  packet: 3592 (5 bytes) at Saturday, December 23, 2023, 9:10:06 AM

who..              77 68 6f 0d 0a
Amended on Sun 24 Dec 2023 08:03 AM by Nick Gammon
Australia Forum Administrator #11
Your prompts end with IAC GA (0xFF 0xF9).

I suggest you try checking "Convert IAC EOR/GA to newline" in the world configuration -> Appearance -> Output tab.

If that works, throw away the plugin.
#12
That worked Nick!! Thank you!