[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]  Lua
. . -> [Subject]  regexp and playing detector
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

regexp and playing detector

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


Posted by Swalec   (24 posts)  [Biography] bio
Date Tue 10 Mar 2009 09:13 PM (UTC)
Message


I'm having problems with a single line trigger on aardwolf.

It looks like this...

addxml.trigger{
enabled = "y",
keep_evaluating = "y",
regexp = "y",
match= "^You receive .* experience points?\.$",
sequence = "1"
}

This is designed to detect when I leave combat (not ideal I know). It should work fine, but it often does not; it's just not triggered. Strangely when it is not triggered "You recieve" is printing out in a different colour.

I've checked for other triggers, but the problem seems to be related to the PlayingDetector. I *think* this causes telnet codes to be sent by aardwolf just before. I think it may be this that's causing the problem, but I don't know why. Disabling this plugin and it works every time.

Incidentally, the problem affects the exp_gain.xml plugin which uses a pretty similar regexp.

Not sure how to debug this further -- comments welcome.

Swalec
[Go to top] top

Posted by Bast   (77 posts)  [Biography] bio
Date Reply #1 on Wed 11 Mar 2009 02:18 AM (UTC)
Message

I have a similar plugin, broadcast_kills and have not seen this behavior. It has this match
match="^You receive (\d+(?:\+\d+)*) experience points?\.$"

However, I remember seeing this issue when using my spellup plugin. When the telnet option changes from fighting to active, a spell would be cast before the above line. The command would echo in the world and the yellow would bleed into the "You receive..." line and the trigger would not fire. This didn't happen all the time, just every now and then. I had to make the spellup plugin not echo the cast command to the world.


If you are looking to detect when you are not fighting, you can also try the broadcast_state plugin I have and listen for the state changes from the telnet options.

Bast

Bast

Scripts: http://bastmush.googlecode.com
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Wed 11 Mar 2009 07:06 AM (UTC)
Message
Triggers should always match, if possible. If they don't, look for subtle differences. One thing I would try is select a word on the offending line, and go to the Display menu -> Text Attributes -> Line Info. Check exactly the line text. For example, is there an extra space before or after the line?

Or maybe did another trigger match first? Try turning on Game menu -> Trace.

- Nick Gammon

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

Posted by Swalec   (24 posts)  [Biography] bio
Date Reply #3 on Wed 11 Mar 2009 09:34 AM (UTC)
Message
"However, I remember seeing this issue when using my spellup plugin. When the telnet option changes from fighting to active, a spell would be cast before the above line. The command would echo in the world and the yellow would bleed into the "You receive..." line and the trigger would not fire."


Yeah, I get the same issue from the spellup plugin, but I'm using a slightly modified version of it (to put a tick timer in place), so I didn't say this originally. Perhaps, it's not my modifications as I thought.

"Triggers should always match, if possible. If they don't, look for subtle differences. "

This is true, but then why would it vary depending on the state of activation of a plugin; I mean, it would always be the same. My trigger does work some times, reliably. As, I said, the same thing seems to affect exp_gain.xml.


"One thing I would try is select a word on the offending line, and go to the Display menu -> Text Attributes -> Line Info. Check exactly the line text. For example, is there an extra space before or after the line?"

This one, I haven't done, but I will check.

"Or maybe did another trigger match first? Try turning on Game menu -> Trace."

Yeah, tried that. The only think that I see immediately BEFORE the "You recieved" message is the "OnPluginTelnetOptions" and "OnPluginBroadcast" to all the other plugins. It's why I thought the telnet codes might be to blame.

I gave brief consideration to the packet debugger also; I decided to ask here, before I spent hours trying to work out what it all meant in case I was missing something trivial.

Thanks for the thoughts

Swalec
[Go to top] top

Posted by Swalec   (24 posts)  [Biography] bio
Date Reply #4 on Wed 11 Mar 2009 09:47 AM (UTC)
Message

I thought to post what I see on trace. So, here it is when it doesn't work...

Your flaming bite INCINERATES the gold bar! \[54\]
The gold bar screams as the flames engulf it!!
TRACE: Executing Plugin xAardwolf_State_Detector script "OnPluginTelnetOption"
TRACE: Executing Plugin Aardwolf_Health_Bar script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Help script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Map script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Stats script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_automaze_swalec script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Regen script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_autohunt_swalec script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_srun_swalec script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Spellups script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Spellups script "OnPluginTelnetOption"
TRACE: Executing Plugin xPlaying_Detector script "OnPluginTelnetOption"
TRACE: Executing Plugin Aardwolf_Health_Bar script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Help script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Map script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Stats script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_automaze_swalec script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Regen script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_autohunt_swalec script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_srun_swalec script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Spellups script "OnPluginBroadcast"
You receive 88 experience points.
You get 117 gold coins from the charred corpse of the gold bar.
Ayla gives you 18 gold coins for the charred corpse of the gold bar.

You can't see it in this picture but "You receive" is in blue (the command colour, same as the trace statements). "88" and "experience points" are in the standard mud colours.

And here is the trace when it works. I've turned off all the plugins which do use telnet codes (Bast's state_detector, your playing detector and my slightly modified spellup plugin).


[Fighting: 724/825hp 864/874mn 1480/1505mv 2452tnl Enemy: 4% ]
TRACE: Matched trigger reset
TRACE: Executing trigger script "kill.auto_cast_trigger"
TRACE: Executing trigger script "process_prompt"
TRACE: Executing Plugin Aardwolf_Health_Bar script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Help script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Map script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Stats script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_automaze_swalec script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_Regen script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_autohunt_swalec script "OnPluginBroadcast"
TRACE: Executing Plugin Aardwolf_srun_swalec script "OnPluginBroadcast"

Your flaming bite INCINERATES a yummy beef pot pie! [52]
Your pierce DISEMBOWELS a yummy beef pot pie! [61]
A yummy beef pot pie is slain by a final deadly stab!!
You receive 100 experience points.
TRACE: Matched trigger "^You receive .* experience points?.$"
TRACE: Matched trigger "^You receive (\d+) experience points?\.$"
TRACE: Executing trigger script "target.autotarg_next"
autokill next
TRACE: Executing trigger script "mobdied"
To level: 2,452 XP (3 h) 39 avg kills. (921 XP/hour)
Ayla gives you 21 gold coins for the perforated corpse of a yummy beef pot pie.

In this case "You recieve" is in standard mud colours.

So there are two triggers being matched in the second case, one of which is your exp_gain. From what I've read of mushclient's text handling, telnet negotiation should all be over by the time it gets this far, but maybe it's not. I've tried modified the regexp to remove the "^" in case the telnet codes came in "on the same line" as "You receive". Again, no luck.

I'm reasonably sure that this is not just a screw up on my behalf but, of course, it's hard to be sure without an independent set up. If it's something funny going on, it *should* be possible to replicate with PlayingDetector and Exp_gain.xml though and without my code.

Again, thanks for the time!

Swalec
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Wed 11 Mar 2009 08:27 PM (UTC)
Message
Quote:

From what I've read of mushclient's text handling, telnet negotiation should all be over by the time it gets this far, but maybe it's not.


Correct. Telnet codes are stripped out well before triggers are matched.

Quote:

You receive 100 experience points.
TRACE: Matched trigger "^You receive .* experience points?.$"
TRACE: Matched trigger "^You receive (\d+) experience points?\.$"


Looks like you have two triggers matching on the experience points thing.

Once again I suggest you check carefully that the line that doesn't match does not have an extra space somewhere. Or indeed, that it is generated by the MUD. If it is blue it sounds like it is a world.Note, not MUD output.

- Nick Gammon

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

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #6 on Wed 11 Mar 2009 09:15 PM (UTC)
Message
To add to Nick's already helpful post... if you hover over the text in question, you can also see what kind of output it is in the tooltip. No special marker would denote mud output, while (note) is shown for notes and (input) for echoed commands.
[Go to top] top

Posted by Swalec   (24 posts)  [Biography] bio
Date Reply #7 on Thu 12 Mar 2009 04:33 PM (UTC)
Message
"Looks like you have two triggers matching on the experience points thing."


The last post had TWO traces. One where the triggers worked, and one where they didn't.

One of the two triggers is yours (from exp_gain.xml) and one isn't mine.

"If it is blue it sounds like it is a world.Note, not MUD output."

I agree, but for the life of me, I can't see why.

"If you hover over the text in question, you can also see what kind of output it is in the tooltip."

Hmmm, didn't know about that.

Well, if I hover over and example where it does NOT work
then it claims that it's "input". This doesn't really make sense to me -- If I send "You recieve" to the mud I should get an error message back.

When it works, then mushclient claims nothing (ie that it's mud output).

"However, I remember seeing this issue when using my spellup plugin. When the telnet option changes from fighting to active, a spell would be cast before the above line. The command would echo in the world and the yellow would bleed into the "You receive..." line and the trigger would not fire. This didn't happen all the time, just every now and then. I had to make the spellup plugin not echo the cast command to the world."


Bast, yes, you are right, I have replicated this. Changing the cast from "Send" to "SendNoEcho" stops the problem. Interestingly, it doesn't need to be "Send" -- I tried "print" then "SendNoEcho" (cause I like being able to see what spellup is doing) but this causes the same issue.

Nick -- as far as I can guess, this means that it's not the telnet that is responsible, but spellup is triggering in response to telnet codes, which is why the two occur together. There does appear to be a problem, though. It looks like a note line immediately before can "bleed through" to the following line; perhaps only when there is a trigger or some such.

Again, thanks for your time. And Bast, thanks for the workaround.

Swalec




[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Thu 12 Mar 2009 08:32 PM (UTC)
Message
Quote:

... as far as I can guess, this means that it's not the telnet that is responsible, but spellup is triggering in response to telnet codes


I am guessing from this that a plugin which is responding to telnet codes, and outputting stuff to the screen, is injecting data where it isn't expected. By that I mean that there are a few checks in the code that the line "type" (input/output/note) transitions correctly. Once I start adding plugin callbacks that get called in odd spots (like telnet codes) it is possible that it bypassed the check.


- Nick Gammon

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

Posted by Swalec   (24 posts)  [Biography] bio
Date Reply #9 on Fri 13 Mar 2009 02:53 PM (UTC)
Message
"I am guessing from this that a plugin which is responding to telnet codes, and outputting stuff to the screen, is injecting data where it isn't expected. By that I mean that there are a few checks in the code that the line "type" (input/output/note) transitions correctly."

This all sounds very plausible, I thought to test it. It now looks even more plausible.

Try the plugin below. It just prints out something when a telnet code comes in. The line immediately below is often misclassified as a result. I'm guessing that you use the classification when you do check for trigger matches?

Anyway, now I have a nice, really simple, test case, I'll see whether I can get a good work around. Bast's solution (don't print anything!) works well but has it's limitations I think.

Swalec


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, March 13, 2009, 2:40 PM -->
<!-- MuClient version 4.37 -->

<!-- Plugin "Test" generated by Plugin Wizard -->

<muclient>
<plugin
name="Test"
author="Swalec"
id="ca6b4207529996c0053b17de"
language="Lua"
save_state="y"
date_written="2009-03-13 14:39:40"
requires="4.37"
version="1.0"
>

</plugin>


<!-- Get our standard constants -->

<include name="constants.lua"/>

<!-- Script -->


<script>
<![CDATA[


-- pull in telnet option handling
dofile (GetPluginInfo (GetPluginID (), 20) .. "telnet_options.lua")

function OnPluginTelnetOption (option)
print "Telnet code coming in"
end -- function


]]>
</script>


</muclient>
[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.


5,760 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]