Add Newline to Prompt modification

Posted by LupusFatalis on Wed 20 May 2009 03:13 AM — 3 posts, 14,871 views.

#0
Ok here is what I want to do, and I think I have to do it in the lua plugin you guys helped me out with.

I want the client to automatically send a carriage return to the mud when it sees this.
"--- Press <enter> for more. ---"

Current plugin follows:
<?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[

partial = ""

function OnPluginPacketReceived (s)

  local t = {}  -- table of reassembled lines

  if s == "> " then
    s = ""
  end

  -- get rid of carriage-returns, add new packet to existing partial one

  partial = partial .. string.gsub (s, "\r", "")
  partial = string.gsub (partial, "\n\255\252\001", "\255\252\001\n")
  partial = string.gsub (partial, "\n\255\252\003", "\255\252\003\n")

  -- turn finished lines into table t
  
  partial = string.gsub (partial, "(.-)\n", 
    function (line) 
      
      -- remove prompt as we add to the table
      
      line = string.gsub (line, "^\027%[0m> ", "\027[0m", 1)
      line = string.gsub (line, "^> ", "", 1)
         
      if line ~= "" then
        table.insert (t, line) 
      end -- if not empty
      
      return ""
    end) -- function
  
  if #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

]]>
</script>

</muclient>
Australia Forum Administrator #1
I can't see where you check for "--- Press <enter> for more. ---". In any case, doesn't the MUD let you configure it to not pause its output like that?
#2
Unfortunately the mud doesn't have that option no. I really don't know LUA though, so no idea where to put this in... the tale end of the packet looks like this...


rd (worn) with a 72 64 20 28 77 6f 72 6e 29 20 77 69 74 68 20 61
very large stee 20 76 65 72 79 20 6c 61 72 67 65 20 73 74 65 65
l claymore in it 6c 20 63 6c 61 79 6d 6f 72 65 20 69 6e 20 69 74
...[36m--- Press 0d 0a 1b 5b 33 36 6d 2d 2d 2d 20 50 72 65 73 73
<enter> for mor 20 3c 65 6e 74 65 72 3e 20 66 6f 72 20 6d 6f 72
e. ---.[0m 65 2e 20 2d 2d 2d 1b 5b 30 6d

So basically if I get that:
...[36m--- Press <enter> for more. ---.[0m

I want to delete the blank line, force a new line, and send the mud an <enter>.
i.e. get
a gazelle leather scabbard (worn) with a very large steel claymore in it

--- Press <enter> for more. --- a leather scabbard (worn) with a very large steel claymore in it

to display as:
a gazelle leather scabbard (worn) with a very large steel claymore in it
a leather scabbard (worn) with a very large steel claymore in it

any ideas?