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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum Goto page 1, 2  Next
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Apr 30, 2008 4:51 pm   

Testing wildcards within {} trigger patterns
 
I was looking at the CMUD source to try and see why wildcards no longer work within {} patterns (they worked in zMUD). And I found that back when I first wrote CMUD, I added a preference option called "Wildcards" to enable/disable this feature. This preference is off by default, and it seems that I never added it to the UI.

So, if you have a chance, please test to see if this works. Enable the Wildcards preference using the command:

#CALL %pref("Wildcards",1)

and then see if you are able to use wildcards within {} patterns. Let me know if this works and I'll add the UI option for this in v2.23. Also, if you can think of a reason why this shouldn't be ON by default, let me know.
Reply with quote
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Wed Apr 30, 2008 5:17 pm   
 
Tested and works.
Code:

<trigger priority="26680" id="2668">
  <pattern>^Hi, {Asilient|*}$</pattern>
  <value>#SAY fired</value>
</trigger>


All I did was tested with #SHOW Hi, Asilient then tested with #SHOW Hi, blah


Quote:
Hi, Asilient
fired
H:6319 M:5992 E:27625 W:26140 B:100% XP:66% [sdb eb lr] <<18:17:01:438>>
Hi, Blah
fired


EDIT: Hope I got you right, at least. Heh. >.>
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Wed Apr 30, 2008 6:04 pm   
 
Yes that test is good and I can also confirm it works in fact I created a trigger loop with my test. Twisted Evil

As for being on by default the only reason I could think of is if it potentially slows CMUD down which I doubt it would anyway.
_________________
Taz :)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Apr 30, 2008 7:19 pm   
 
It would slightly slow down the initial conversion from zScript trigger pattern into a regular expression pattern. When "Wildcards" is enabled, then the pattern within the {} is recursively passed to the regex conversion routine, otherwise it just quotes any wildcard characters. Since this is just done once when the trigger is first used, I doubt the speed difference will be noticeable at all.
Reply with quote
Rorso
Wizard


Joined: 14 Oct 2000
Posts: 1368

PostPosted: Wed Apr 30, 2008 8:00 pm   
 
The bad thing with making it the default now could be if people are matching {} characters. Wouldn't those scripts then need to be changed to ~{~}?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Apr 30, 2008 8:32 pm   
 
No - they were always a special character and always needed escaping.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Apr 30, 2008 9:45 pm   
 
Fang is correct. This change only effects wildcard characters within the {}, such as *. I can see where this might cause a side-effect if someone was using {@varname} and @varname was a string list that happened to have wildcard characters in it, like "item *1*|item *2*|..." etc.

But since this is how it worked in zMUD, it seems like CMUD should handle it the same way. I don't remember any specific reason why I turned it off and couldn't find any form post about it with some simple searching. But since I've seen several questions recently about this, I think it might be better to turn it back on by default.
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed May 28, 2008 3:46 pm   
 
Was this ever enabled as default in CMUD 2.25? Im assuming not since its not working for me, but wanted to check. And this would work for any of the predefined wildcards yes? ie %w %d etc.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Wed May 28, 2008 4:09 pm   
 
By default usually means that if you create a new session then it will already be checked.
But your pre-existing sessions will remain as they were.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed May 28, 2008 4:12 pm   
 
My packages were created fresh in 2.25, not carried foward from a previous version... So are they default?
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Wed May 28, 2008 4:17 pm   
 
Then I would have to say probably so. I just check and both the untitled session and the session I just created had it set.

To check your sessions click prefs -> scripting -> Allow wildcards within {} trigger patterns.

If it is not checked check it. If it IS checked show me the patterns that are not working. And the text they are supposed to match.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed May 28, 2008 4:25 pm   
 
Trigger pattern is ^({@{dbvar}})$

dbvar = {"This is a (%w) test string."="test value"|key2 = val2}

output is

This is a good test string.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Wed May 28, 2008 4:57 pm   
 
I needed to set the variable to be a database variable and put the keys in manually but yeah, it worked after that.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger priority="10" copy="yes">
    <pattern>^({@{dbvar}})$</pattern>
    <value>#show {This fired the trigger. {%1}}</value>
  </trigger>
  <var name="dbvar" type="Record" copy="yes">key2 = val2|This is a (%w) test string.=test value</var>
</cmud>

You would copy the text in the box and paste it into the tree view of the package editor to recreate what I used.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed May 28, 2008 5:05 pm   
 
What was your output? Just curious as to what {%1} reports back as.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Wed May 28, 2008 6:30 pm   
 
This is a good test string.
This fired the trigger. {This is a good test string.}
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed May 28, 2008 6:35 pm   
 
How, if possible, could I pull out the Good in the above script?

so I could assign good to a var inside the trigger?
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Wed May 28, 2008 6:47 pm   
 
I don't know and I don't have time to test so, odds are Vijilante or Zugg will have to answer that one sorry.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed May 28, 2008 7:16 pm   
 
Can anyone help me further with this?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed May 28, 2008 10:30 pm   
 
Quote:

How, if possible, could I pull out the Good in the above script?

so I could assign good to a var inside the trigger?


You could use #CALL %match({%1},"*(Good)*", @vartoputGoodin). First parameter is the string you want to pull data out of. Second parameter is the pattern you want to use. Third and subsequent parameters are the names of the variables you want to put the data into.
_________________
EDIT: I didn't like my old signature
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed May 28, 2008 10:34 pm   
 
could I do?

#CALL %match({%1},"*(@stringlist)*", and then somehow store %i into @vartoputgoodin)

%i being the string in the list that matched?
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed May 28, 2008 10:39 pm   
 
Just a thought but maybe...

#FORALL @stringlist {#CALL %match({%1}, "*(%i)*", @vartoputwordin)}
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Tue Jun 03, 2008 3:22 pm   
 
Still looking for a solution to this. Just a recap on what I'm looking for.

I currently have
Code:

#TR {^({%%dbkeys(@dbvar)})$} {#SHOW %db(@dbvar,%replace(%trigger,@wildcarword,"(%w)"))
#SHOW {%1}}

#VAR wildcardword good
#VAR dbvar {This is a (%w) test string.=val1|key2=val2}


If MUD output is

This is a good test string.

I want the output of my MUD trigger to be

val1
{good}

Currently of course my output is
val1
{This is a good test string.}
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jun 03, 2008 5:51 pm   
 
You have an extra set of parentheses in your trigger pattern. Change it to:
Code:
#TR {^{%%dbkeys(@dbvar)}$}

edit:
Actually, it looks like Arminas' code also had that extra set of parentheses. Maybe you should go back to see whether you actually need the %dbkeys bit.
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Tue Jun 03, 2008 5:55 pm   
 
Thanks, I knew it had to be something small, but yes, that makes sense.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jun 03, 2008 8:06 pm   
 
Maybe you could explain in a little more detail exactly what you are trying to do. From what you have so far, I have a feeling you may have some problems.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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