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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Experimenting with Triggers

Experimenting with Triggers

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


Posted by Boko346   (7 posts)  [Biography] bio
Date Mon 24 Feb 2014 04:51 PM (UTC)

Amended on Mon 24 Feb 2014 04:53 PM (UTC) by Boko346

Message
I've got a little project I'm working on and to say I don't understand triggers as they are in MUSHclient is an understatement. The game I play has the ability to sniff out people who are spoofing other people by adding a little tag to the front of everything they do with their name and dbref. I like this feature, but it is annoying and spammy. I don't want to see it all the time, but I would like to set up a trigger that hides it 90 percent of the time, then I can just check to disable the trigger to have it showing again. Using my own name, the tag would look something like this. NOTE: DBREF can be any number between 1 and 6 digits in length.

[Boko346(#<MY DBREF>)<potentially other things that don't matter>]

The line always starts with that and I wish to hide that and only that. I tried starting out simple and working my way to a more complicated thing, but it doesn't seem to be firing to begin with so I'm not sure what I'm doing wrong trigger-wise. Can anyone help? My current expression is this:

^\[*\(#*\)\]
[Go to top] top

Posted by Boko346   (7 posts)  [Biography] bio
Date Reply #1 on Mon 24 Feb 2014 08:37 PM (UTC)

Amended on Mon 24 Feb 2014 08:38 PM (UTC) by Boko346

Message
I've been working on it and I've got it to the point where I can find and delete the whole line, but I only want to take off the beginning tag. Is there a way to do this easily? I know the trigger can automatically echo the last wildcard, but I lose all color involved with it.

My current solution is this:

Trigger: [*(#*)*] *
Send: think %4

(think is a way to send a message to yourself)
Just 'Omit from Output' is checked. Everything else is default.

This works, but again, no color on the line. Is there an easy way to fix this?
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Mon 24 Feb 2014 11:05 PM (UTC)
Message
This will be close to doing it:


<triggers>
  <trigger
   enabled="y"
   match="[*(#*)*] *"
   omit_from_output="y"
   send_to="14"
   sequence="100"
  >
  <send>

for i, style in ipairs (TriggerStyleRuns) do
  
  if i &gt; 4 then
    ColourTell (RGBColourToName (style.textcolour), 
                RGBColourToName (style.backcolour), 
                style.text)
  end -- if

end -- for

print ()  -- finish line off

</send>
  </trigger>
</triggers>



Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


This uses a bit of scripting to get the colour style runs from the line you receive and then "note" then into the output window.

Each colour change will result in a style run. You may need to experiment a bit to find which styles you want to omit. That is, change the "if i > 4 then" above to some suitable number. It might be 3, it might be 5 or 6.

What that effectively does is skip the first few styles (assuming the MUD consistently colours the DBREF) and then echoes back the rest.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Boko346   (7 posts)  [Biography] bio
Date Reply #3 on Tue 25 Feb 2014 02:28 AM (UTC)
Message
I do apologize for explaining this in a super complicated way. I just seem to be way too far behind on my XML and whatnot. My end goal would be equivalent to censoring a word at the start of a sentence. Maybe I'm getting way too complicated, but generally I need a trigger that will see the phrase

Bob went to the park.

and remove 'Bob', only pasting

went to the park.

to the world.

Only in this case the item I'm trying to remove would be matched by the flag: [*(#*)*] *

I can get rid of that but the problem is if the word 'park' and only the word park were in green, it would not pick that up. It would post it all in the world's default color, or if I send it to 'output' it will be in blue.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Tue 25 Feb 2014 09:04 PM (UTC)
Message
I understand what you are trying to do, but in your example "Bob went to the park" that is easy unless (say) "Bob" is in a different colour than "went to the park". If not, the whole thing is easy (ie. you don't have to worry about colours).

Try pasting in what I showed. You don't need to worry about XML, just read this:

Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


Then experiment with changing the "4" to maybe "3" or "5" and see if it works.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Boko346   (7 posts)  [Biography] bio
Date Reply #5 on Tue 25 Feb 2014 10:14 PM (UTC)

Amended on Tue 25 Feb 2014 10:29 PM (UTC) by Boko346

Message
I tried it out with a few different setups and no matter which number I use, the result is a empty black space in time with the text scroll. The actual tag enclosed in brackets is only one color, and it is the same default color as the rest of it. Unfortunately, this is also a game where you can make your message one color or 256 colors. I think that might be what's messing it up.

Just to be clear, I'll give an actual example of what the text would look like. I'm starting to think maybe I'm not doing my thing wrong but instead it's a limitation of the technology. Your average post would look like this.

[Boko346(#13461),saypose] Boko346 goes to the park.

or in the case of an emit:

[Boko346(#13461)] This is just an emit. The room would see this without a name.

No matter what the whole thing between brackets would be one color, the same color as the default text color of the game. Everything after the tag could be one color or a hundred colors. What makes me a little suspicious that it might not be me is that I am highlighting the tag and right clicking and choosing 'highlight word' and that isn't setting off the trigger to even recolor the word. I'm using version 4.84 right now.
[Go to top] top

Posted by Scarn   (47 posts)  [Biography] bio
Date Reply #6 on Tue 25 Feb 2014 11:42 PM (UTC)

Amended on Wed 26 Feb 2014 08:32 PM (UTC) by Nick Gammon

Message
Can someone post this as a new topic? When I try I am getting an SQL error.

My first client was MUSHclient, and still believe it is the most powerful client available.. the only thing lacking is the map. I've tried to get the map plugin working (I actually play T2T MUD), but compared the CMUD map for editing/running I just can't get it up to standard.

So here is my idea, I've made a script in CMUD that generates directions from A to B and then converts them into whatever I desire (at the moment, MUD recognized directions for helping out people).

Is there a way I can use MUSH to send a command to CMUD and return the above string?

Once I have made that initial link, I believe I will be able to sync rooms, travel and follow progress on the CMUD map whilst it is in offline mode. And then position the CMUD map within my MUSH GUI (of miniwindows etc..)

Am I wasting my time trying to dig into this? I have only a limited knowledge of coding (although recently made my first C# program from getting data off my MUD and converting it into a form generated table through APIs).

Thanks in advance, I hope there is a way to make this work so I can come back to CMUD!

-Scarn.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Wed 26 Feb 2014 08:31 PM (UTC)
Message
Nick Gammon said:

Can someone post this as a new topic? When I try I am getting an SQL error.


Please copy and paste the SQL error so I can fix it.


Re-posted here:

http://www.gammon.com.au/forum/?id=12385

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Wed 26 Feb 2014 08:36 PM (UTC)
Message
Boko346 said:

I tried it out with a few different setups and no matter which number I use, the result is a empty black space in time with the text scroll. The actual tag enclosed in brackets is only one color, and it is the same default color as the rest of it.


Is that colour always the same? In that case you can just ColourNote it.

For example:


<triggers>
  <trigger
   enabled="y"
   match="[*(#*)*] *"
   omit_from_output="y"
   send_to="12"
   sequence="100"
  >
  <send>
ColourNote  ("green", "", "%4")
</send>
  </trigger>
</triggers>



Change "green" to whatever colour you want the message to come out in.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Boko346   (7 posts)  [Biography] bio
Date Reply #9 on Thu 27 Feb 2014 02:25 AM (UTC)

Amended on Thu 27 Feb 2014 02:37 AM (UTC) by Boko346

Message
Okay. So I was looking at your code for the first example and your code for the second example. The second example is closer to what I want. It is similar to my original solution of echoing 'think %4'. Your solution is a better one because it is completely contained in MUSHclient and doesn't require me repeatedly (sometimes up to 15 times a second) spamming the particular game I'm at with 'think' commands. The problem still remains, and that is the fact that the %4 part remains in one color. Getting the styling and formatting from that and echoing it is a big challenge. For some reason the code from the first is a blank line. Maybe it's because I don't quite understand style runs or ipairs properly. I know how to code in a number of languages. I just don't have any experience with LUA. I can see what you're trying to do in the first and that's what I want. It's just a matter of debugging.

I think the big issue is that the text after the tag is usually the same color as the tag, but sometimes it's not. Doing more testing, it looks like it will post the whole line, tag and all if I make I > 0, but anything higher than 0 will result in it only posting text after the color changes to something else. The result is blank as I stated previously. Is there a way to only check for formatting for the fourth wildcard in my trigger, the %4 in your second example?
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Sat 01 Mar 2014 02:47 AM (UTC)
Message
Look, it's all there somewhere. My more elaborate example with the style runs shows how you can find the colour of parts of the text. Each different colour (foreground or background) starts a style run.

If the whole line is one colour you will have one style run.

You could find the colour of that and use that instead of "green" in reply #8.

Quote:

Maybe it's because I don't quite understand style runs or ipairs properly.


You can print the style runs.

eg.


require "tprint"

tprint (TriggerStyleRuns)


Then it might become clearer.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Boko346   (7 posts)  [Biography] bio
Date Reply #11 on Sat 01 Mar 2014 05:50 AM (UTC)

Amended on Sat 01 Mar 2014 06:25 AM (UTC) by Boko346

Message
I got it figured out. The code Nick gave on the very first reply was the correct code after all. My problem was that most of the time, the tag was the same color as the line it followed. Telling it to highlight the phrase didn't work because it was in square brackets [] and apparently \b does not play well with square brackets. The only problem left to solve, is that the hyperlink plugin is not playing well with it.

From what it looks like, both the hyperlink plugin and the custom script is picking up the text from the world and echoing it back to me. The result is a double-posted line, one where my script worked its magic and one and not the other. Is there a way to send the output of one plugin to the other before echoing it? Here is an example of what I'm talking about:


Original post: [Random Tag To Remove] Bob went to the park. Here is a picture of the park! http://www.parks.com/

What I see:
Bob went to the park. Here is a picture of the park! http://www.parks.com/ (The hyperlink doesn't work here.)
[Random Tag To Remove] Bob went to the park. Here is a picture of the park! http://www.parks.com/ (The Hyperlink does work here)
[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.


27,110 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 HostDash]