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
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Feb 05, 2009 10:56 pm   

Odd Regex Issue [Solved]
 
I copied and pasted the pattern from Spellbot-t into Spellbot-t2 and yet the pattern:

Diamante tells you 'cc: perm'

fails to match.

Spellbot-t
Code:

<trigger name="Spellbot-t" priority="1910" regex="true" enabled="false" id="94">
  <pattern>^(?:\(Imm\) )?(?:The ghost of )?([\w']+|A masked swashbuckler|\(An Imm\)){1,2} tells you (?:\([^\)]+\) )?'(cc:(?: )?(.*))'</pattern>
  <value>#IF ((%begins("permanency",%3)) OR (%begins("chain lightning", %3)) OR (%begins("fireball", %3)) OR  (%begins("disjunction", %3)) OR (%begins("acid blast", %3)) OR (%begins("blizzra", %3)) OR  (%begins("disjunction", %3)) OR  (%begins("acid blast", %3)) OR (%begins("blizzra", %3)))
{
 #send {"reply Not on your life, try another. (ooc: Automated response to spellbot request)"}
}
{
$cur_posn=@posn
#send {"stand"}
#send {"c '"%3"' "%1}
#send {$cur_posn @bed}
regen
}
</value>
</trigger>


Spellbot-t2
Code:

<trigger name="spellbot-t2" priority="980" enabled="false" id="98">
  <pattern>^(?:\(Imm\) )?(?:The ghost of )?([\w']+|A masked swashbuckler|\(An Imm\)){1,2} tells you (?:\([^\)]+\) )?'(cc:(?: )?(.*))'</pattern>
  <value>#IF ((%begins("permanency",%3)) OR (%begins("chain lightning", %3)) OR (%begins("fireball", %3)) OR  (%begins("disjunction", %3)) OR (%begins("acid blast", %3)) OR (%begins("blizzra", %3)) OR  (%begins("disjunction", %3)) OR  (%begins("acid blast", %3)) OR (%begins("blizzra", %3)))
{
 #send {"reply Not on your life, try another. (ooc: Automated response to spellbot request)"}
}
{
$cur_posn=@posn
#send {"stand"}
#send {"c '"%3"' "%4}
#send {$cur_posn @bed}
regen
}
</value>
</trigger>


I did this because the regex I had made for spellbot-t2 which was similar to spellbot-t wasn't working. So I tried having them the same, but it didn't work.
_________________
Listen to my Guitar - If you like it, listen to more

Last edited by chamenas on Thu Feb 05, 2009 11:57 pm; edited 1 time in total
Reply with quote
calesta
Apprentice


Joined: 07 Dec 2008
Posts: 102
Location: New Hampshire, USA

PostPosted: Thu Feb 05, 2009 11:44 pm   
 
Spellbot-t2 doesn't appear to have the regex flag turned on.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Feb 05, 2009 11:57 pm   
 
doh... man I'm stupid.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Fri Feb 06, 2009 12:01 am   
 
Er. Matches for me? Do you mean that it fails to function inside the trigger?

Btw, I think you can clean up your pattern a lot... I would use
Code:
^(?:\(Imm\) )?(?:The ghost of )?([\w']+|A masked swashbuckler|\(An Imm\)) tells you .*'cc: *([A-Za-z ]+)'


Although I was unsure about the section where you had used {1,2}, as it didn't make sense to me that you would be able to have more than one "name" in a tell.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Feb 06, 2009 12:08 am   
 
First name and Last name Wink Also, sometimes the Imms use mobs with first and last names, most players dont. I dont think any do.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Fri Feb 06, 2009 1:42 am   
 
Oh, yeah, that makes sense. Well you should fix it, since it wouldn't work anyway--it'll need a space inside the parentheses.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Feb 06, 2009 2:10 am   
 
This regex above would work the same way as mine? What if the tell contains - ', I would likely add those in to the [A-Za-z ]+ as well, no?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Fri Feb 06, 2009 5:54 am   
 
Code:
^(?:\(Imm\) )?(?:The ghost of )?([\w']+(?: [\w']+)?|A masked swashbuckler|\(An Imm\)) tells you .*'cc: *([-'A-Za-z ]+)'


Fixed to account for having two names, or the characters - or ' in the spell name. The reason why I switched to using a character class as opposed to just .* for the name of the spell that they want you to cast is so they can't do something like

tell chamenas cc: heal';give all gold to gamma;

which could then cause you to do something you didn't intend to do (and potentially make me rich). Anyway, you can never be too careful.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Feb 06, 2009 6:14 am   
 
lol, yes, that's why, in the other thread, I have an exception list. But I can certainly see how they could try to abuse it that way too. Thanks.
_________________
Listen to my Guitar - If you like it, listen to more
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