Register forum user name 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Add Newline to Prompt modification

Add Newline to Prompt modification

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by LupusFatalis   (154 posts)  Bio
Date Wed 20 May 2009 03:13 AM (UTC)
Message
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>
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 20 May 2009 11:39 PM (UTC)
Message
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?

- Nick Gammon

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

Posted by LupusFatalis   (154 posts)  Bio
Date Reply #2 on Thu 21 May 2009 05:38 PM (UTC)
Message
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?


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.


14,178 views.

It is now over 60 days since the last post. This thread is closed.     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.