Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Wed Nov 18, 2015 9:19 am   

Having problems capturing first line that comes right after prompt
 
Hi guys, I had this problem for an eternity now and have usually resorted to workarounds, but today i need to force the issue and I hope someone can help me out as the problem seems to be pretty basic at it's core.

The problem: Capturing the first line that comes right after prompt, will capture part of prompt
------------------------------------------
Trigger code:
<trigger priority="99" case="true" trigontrig="false" prompt="true" id="1349">
<pattern>(%w*) hates your guts!</pattern>
<value>#var monster %1
#print @monster set
</value>
</trigger>

And here is the result:

<901hp 924ma 361mv>A goblin hates your guts!
hp 924ma 361mv>A goblin set
You hit a goblin extremely hard.
------------------------------------------
Checking and unchecking Trigger on Trigger does nothing
And with Trigger on Prompt disabled, the trigger will not capture anything at all.
If I force the start of the line and use <pattern>^(%w*) hates your guts!</pattern> then my script will not capture anything at all with Trigger on Prompt and without it.


------------------------------------------
<trigger priority="99" case="true" trigontrig="false" prompt="true" id="1349">
<pattern>^(%w*) hates your guts!</pattern>
<value>#var monster %1
#print @monster set
</value>
</trigger>

Result:
<901hp 924ma 360mv>A kobold youth hates your guts!
You hit a kobold youth extremely hard.
------------------------------------------

I could make a <@prompt>@pattern trigger, but my mud also sends these same lines without prompt sometimes, so this would mean that I would have duplicate my triggers, one with <@prompt> and then add the same trigger without prompt, which is not acceptable.

I have tried setting my prompt in Prefs and i have tried checking and unchecking Use GA/EOR for Prompt in Perfs with no changes.

THanks
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Wed Nov 18, 2015 10:08 am   
 
Here is raw data from debugger without script code.

12:56:12.982p | 901hp 927ma 361mv>
12:56:18.177p | say bla<CR><LF>
12:56:18.177p | kill kobold<CR><LF>
12:56:18.692p | You say 'bla'<ESC>[0m<CR><LF><CR><LF>
12:56:12.982p | <901hp 927ma 361mv>
12:56:18.177p | kill kobold<CR><LF>
12:56:18.692p | <901hp 927ma 361mv>
12:56:19.082p | A female kobold hates your guts!<CR><LF>
12:56:19.082p | You hit a female kobold extremely hard.<ESC>[0m<CR><LF><CR><LF>
12:56:19.082p | <901hp 927ma 361mv><IAC><SB><69><1>OPPONENT_HEALTH<2>60<IAC><SE><IAC><SB><69><1>OPPONENT_LEVEL<2>5<IAC><SE><IAC><SB><69><1>OPPONENT_NAME<2>female kobold<IAC><SE>
12:56:21.188p | You hit a female kobold extremely hard.<CR><LF>
12:56:21.188p | A female kobold misses you with her hit.<CR><LF>
12:56:21.188p | You hit a female kobold very hard.<CR><LF>
12:56:21.188p | A female kobold is stunned, but will probably regain consciousness again.<ESC>[0m<CR><LF><CR><LF>
12:56:21.188p | <901hp 927ma 361mv>
12:56:21.578p | <IAC><SB><69><1>OPPONENT_HEALTH<2>-3<IAC><SE>
12:56:25.681p | You massacre a female kobold to small fragments with your hit.<CR><LF>
12:56:25.681p | A female kobold is dead! R.I.P.<CR><LF>
12:56:25.681p | You gain 275 bonus experience!<CR><LF>
12:56:25.681p | Total exp for kill is 1179.<CR><LF>
12:56:25.681p | Your blood freezes as you hear a female kobold's death cry.<ESC>[0m<CR><LF><CR><LF>


Now here is that same log i see when it is shown mud window

<901hp 927ma 361mv>say bla
kill kobold
You say 'bla'
<901hp 927ma 361mv>A female kobold hates your guts!
hp 927ma 361mv>A female kobold set
You hit a female kobold extremely hard.

<901hp 927ma 361mv>You hit a female kobold extremely hard.
A female kobold misses you with her hit.
You hit a female kobold very hard.
A female kobold is stunned, but will probably regain consciousness again.


<901hp 927ma 361mv>You massacre a female kobold to small fragments with your hit.
BONUS XP: 275
Total XP: 1,179
Your blood freezes as you hear a female kobold's death cry.
Reply with quote
mikeC130
Wanderer


Joined: 03 Jul 2006
Posts: 63

PostPosted: Wed Nov 18, 2015 12:33 pm   
 
get rid of the asterisk in your trigger. just (%w) will capture the single word (e.g. "goblin") which should be enough for the system. The asterisk is making the trigger capture EVERYTHING prior to the targeted phrase.

Mike

ETA: If you need to capture the description as well, such as "female kobold" in your example, you could include the A in your trigger pattern before an asterisk, such as "A (*) hates your guts!"
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3824
Location: Pensacola, FL, USA

PostPosted: Wed Nov 18, 2015 2:18 pm   
 
The issue is with the prompt itself, i would just suppress it:

Code:
#TR {<(%d)hp (%d)ma (%d)mv>} {#SUB {}}


that should strip the prompt out once more text from the mud gets appended to it
the most recent prompt should still show
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Wed Nov 18, 2015 4:43 pm   
 
mikeC130 wrote:
get rid of the asterisk in your trigger. just (%w) will capture the single word (e.g. "goblin") which should be enough for the system. The asterisk is making the trigger capture EVERYTHING prior to the targeted phrase.

Mike

ETA: If you need to capture the description as well, such as "female kobold" in your example, you could include the A in your trigger pattern before an asterisk, such as "A (*) hates your guts!"



As an example, these solutions will not work on mob names like: Monster, is the king of monsters.
Because there is a huge variety in mob names, but because they always start with a letter, not a number, i tried using (%w*) instead of an outright (*), but it didn't help either.
I could've gotten away with using @varlist (*), where @varlist is {A,The,An}, but sometimes the mob names starts with Monster name without using any of these..

shalimar wrote:
The issue is with the prompt itself, i would just suppress it:

Code:
#TR {<(%d)hp (%d)ma (%d)mv>} {#SUB {}}


that should strip the prompt out once more text from the mud gets appended to it
the most recent prompt should still show


Thank you for the suggestion, but here is the result:

<901hp 462ma 266mv>say bla
kill kobold
You say 'bla'

A male kobold hates your guts!
hp 469ma 268mv>A male kobold set
You pound a male kobold very hard.

It seems that even when it's #subbed, it's still being captured into the trigger.
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Wed Nov 18, 2015 5:24 pm   
 
Alright, so as long as there are no obvious solutions and it's the mud itself that's at fault (supposedly), i've decided to incorporate yet another 2 step workaround:

<trigger priority="99" case="true" prompt="true" id="1349">
<pattern>(*) hates your guts!</pattern>
<value>#T+ promptcheck
#var monster %1
#print @monster set
</value>
</trigger>

<trigger name="promptcheck" priority="3736400" enabled="false" id="373640">
<pattern><(%d)hp (%d)ma (%d)mv></pattern>
<value>#var promptcheck {"<"%1hp %2ma %3mv">"}
#var monster %replace(@monster,@promptcheck,"")
#T- promptcheck</value>
</trigger>


If anyone has a more elegant solution or has other thoughts on why this problem is occuring and how to fix it without any workarounds, please let me know and thanks everyone for their help.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3824
Location: Pensacola, FL, USA

PostPosted: Wed Nov 18, 2015 6:23 pm   
 
Thats an issue of priority, give the new trigger that you made with my code a lower number, so it fires before the old one you made.
That setting is located at the bottom of the trigger in the settings editor, in the 'more' panel.
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Thu Nov 19, 2015 12:47 am   
 
You could try this regex pattern (make sure the regular expression box is ticked): ([^>]+) hates your guts!

This will match any character except ">", so it won't catch the prompt. Of course, this is assuming there are no mobs that have a literal > sign in their name.
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Thu Nov 19, 2015 9:37 pm   
 
shalimar wrote:
Thats an issue of priority, give the new trigger that you made with my code a lower number, so it fires before the old one you made.
That setting is located at the bottom of the trigger in the settings editor, in the 'more' panel.


Thanks Shalimar, that helped, never paid any attention to priority, i guess it's quite useful.

Daern wrote:
You could try this regex pattern (make sure the regular expression box is ticked): ([^>]+) hates your guts!

This will match any character except ">", so it won't catch the prompt. Of course, this is assuming there are no mobs that have a literal > sign in their name.


Do i still use %1 etc to capture the Regex pattern ? Never used that before

-----------------

On a different theme, does anyone else have problems posting messages ? I keep clicking submit for hundreds of times and it just shows me preview and doesn't post the response..
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3824
Location: Pensacola, FL, USA

PostPosted: Thu Nov 19, 2015 9:48 pm   
 
I have not been noticing any posting issues like that, no...

As for the script section of the trigger, %1 is fine to use, it should never appear in the pattern, regex or not
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
Anrok
Apprentice


Joined: 19 Nov 2010
Posts: 119

PostPosted: Thu Nov 19, 2015 10:31 pm   
 
shalimar wrote:
I have not been noticing any posting issues like that, no...

As for the script section of the trigger, %1 is fine to use, it should never appear in the pattern, regex or not


I take my hat off to you Shalimar, this #sub trigger is working very well indeed.
Btw, is it possible to replace the empty #subbed line with a prompt of my own, but one that wouldn't be captured by (*) pattern ?

Also

<trigger priority="3763350" regex="true" prompt="true" id="376335">
<pattern>([^>]+) hates your guts! </pattern>
<value>#print REGEX test:%1</value>
</trigger>

Not working for me, is my pattern wrong?.

<921hp 912ma 365mv>say bla
kill street
You say 'bla'

<921hp 912ma 367mv>The streetsweeper hates your guts!
You pound the streetsweeper very hard.

<921hp 912ma 367mv>You pound the streetsweeper very hard.
The streetsweeper misses you with his hit.missed
You pound the streetsweeper very hard.
You pound the streetsweeper very hard.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3824
Location: Pensacola, FL, USA

PostPosted: Fri Nov 20, 2015 12:43 am   
 
the output of the #PRINT command is not processed by triggers
so long as you include a %crlf at the end of the #SUB string, it should work
I typically use button gauges to display the data that is delivered in the prompt.

As for Daern's code... it looks to be anchored at the line start with only an '>' for the prompt, expand the prompt appropriately?
I'm not good with raw regex.
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Fri Nov 20, 2015 1:15 am   
 
It's not anchored to the start of the line, in this case the ^ is being used as a negation operator since it's within []. It looks like the problem is actually that there's a space at the end.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3824
Location: Pensacola, FL, USA

PostPosted: Fri Nov 20, 2015 7:24 am   
 
Ahhh yes, i forgot about the negative ranges.
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net