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
➜ Removing prompt from logs to put it simply.
|
Removing prompt from logs to put it simply.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Wuggly
USA (112 posts) 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%] >
| | Top |
|
| Posted by
| Wuggly
USA (112 posts) 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. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) 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 | | 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.
13,643 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top