[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Removing prompt from logs to put it simply.
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Removing prompt from logs to put it simply.

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


Posted by Wuggly   USA  (112 posts)  [Biography] bio
Date Wed 27 Apr 2016 08:28 PM (UTC)

Amended on Wed 27 Apr 2016 10:41 PM (UTC) by Wuggly

Message
Hello,
I have been working on something that has been boggling my mind for a few days now.

Basically, what I have done, is I made a trigger that captures every line, which is used to log specific things in the MUD I play.

I am trying to make an option that will automatically remove their prompt from the log. (I know, rough territory I am going into).

I have made two different things for this trying to figure out how to do it. The first one gives the player 10 seconds to copy their prompt then an input box pops up and asks them to paste it in.

From there, it converts it to an expression. I have also made one that converts it into a regular expression, and both adds a space after it since I noticed there is always a space after your prompt in this MUD.

The problem is I am clueless as how to compare it with the trigger that logs everything since I can't seem to use a simple if line == prompt statement since it compares it with the escapes or with the regex one the %d's and such.

Another attempt, I tried making a second trigger that would match on their prompt, which would set a variable updating exactly what their current prompt is, however I cannot do this since the trigger cannot be a variable. ie: match=their_converted_prompt

The trigger that logs everything is simple, just a * then the function uses the line to append it to notepad after a bunch of if statements so it only logs specific things.

Any ideas on how I could go about this? I've looked into comparing it with like string.match so it could be compared to an expression, but became lost on that as well.


Anyways, I thought the converting part might be useful for others if needed to convert something like that in a script, so here's that code. It's not perfect, but could easily be fixed up if someone were to use it. I just never finished it as I found it to be pointless to make with what I was trying to accomplish.


For basic expression, with a space added after prompt.

function promptConvert ()
 prompt = utils.inputbox ("Paste your full prompt into the box below", "Prompt Converter BASIC", "", "Courier", 9)
 if prompt ~= nil then 
   promptResult = string.gsub (prompt, "[%%%]%^%-$().<>:[*+?]", "%\\%1")
   promptResults = string.gsub (promptResult, "%d+", "%*") .. " "
   print(promptResults)
 end -- prompt
end -- function promptConvert

Example:
Input  -- <500hp(500) 500ma(500) 500mv(500)(78453) 221900gp ft: none sp: [commn] >
Output -- \<*hp\(*\) *ma\(*\) *mv\(*\)\(*\) *gp ft\: none sp\: \[commn\] \> 


For regular expression, with a space added after prompt.

function promptConvert ()
 prompt = utils.inputbox ("Paste your full prompt into the box below", "Prompt Converter REGEX", "", "Courier", 9)
 if prompt ~= nil then 
   promptResult = string.gsub (prompt, "[%%%]%^%-$().[*+?]", "%%%1")
   promptResults = string.gsub (promptResult, "%d+", "%%d") .. " "
   print(promptResults)
 end -- prompt
end -- function promptConvert

Example:
Input  -- <500hp(500) 500ma(500) 500mv(500)(78453) 221900gp ft: none sp: [commn] >
Output -- <%dhp%(%d%) %dma%(%d%) %dmv%(%d%)%(%d%) %dgp ft: none sp: %[commn%] > 
[Go to top] top

Posted by Wuggly   USA  (112 posts)  [Biography] bio
Date Reply #1 on Sat 30 Apr 2016 12:09 PM (UTC)

Amended on Sat 30 Apr 2016 01:24 PM (UTC) by Wuggly

Message
I just wanted to say I've figured it out. I feel very dumb now.

Turned out to be very simple once I saw string.find could be used in an if statement without having to compare to something.

Before I was doing things like if line == string.find and of course that didn't work.

For anyone interested. I simply detected if a line contained both a < and >.

if string.find(line, "<") and string.find(line, ">") then


Wish I could delete this thread.
[Go to top] top

Posted by Nick Gammon   Australia  (21,609 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sat 30 Apr 2016 09:44 PM (UTC)
Message
How about:


if string.find(line, "<.*>")  then

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


2,245 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]