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
miegorengman
Beginner


Joined: 05 Sep 2008
Posts: 19

PostPosted: Sat Jun 11, 2022 4:16 am   

CMUD triggering with special characters
 
I would like to trigger off text that includes special characters and I am at a loss for how to tell CMUD something like an asterisk is just a normal character in this context Shocked

for example, I want to trigger off the following line of text and grab the number following the asterisk and add it to a variable list. to make the pattern as flexible as possible I tried to only use the initial asterisk and the opening bracket as a reference

*423 [Mar 15, 2021] March Reboot (Gaborn)



Code:

<trigger priority="35130" id="3513">
  <pattern>*(*) [</pattern>
  <value>#var unreadnotes %additem(%1,@unreadnotes)
</trigger>



Thank you for reading Smile [/code][/b]
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Sat Jun 11, 2022 8:13 pm   
 
Escape everything not a regular character...which will assure you get what you want.

<pattern>~*~(~*~) ~[</pattern>
Reply with quote
shalimar
GURU


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

PostPosted: Sat Jun 11, 2022 9:13 pm   
 
#TR {~*(%d) ~[} {#var unreadnotes %additem(%1,@unreadnotes)}
_________________
Discord: Shalimar#3679
Reply with quote
miegorengman
Beginner


Joined: 05 Sep 2008
Posts: 19

PostPosted: Sat Jun 11, 2022 11:47 pm   
 
thank you very much. i tried both ideas and neither added to the list. i tried

Code:
~*(*) ~[


and it worked. thank you for the help


your knowledge has inspired related questions:

Q. so the ~ character, it "escapes" the next character only? or does more than that?

Q. i have seen %d in use but dob't really understands what it is and how to use it properly. i have also seen %w. is this effectively the same thing? are these temporary variables?

thanks again
Reply with quote
shalimar
GURU


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

PostPosted: Sun Jun 12, 2022 1:23 am   
 
Correct, ~ escapes (makes the parser ignore any special uses for) the character immediately following it. That is all.

In '#HELP #TRIGGER' there is a link to 'pattern matching symbols'.
I prefer to use typed wildcards to make for a tighter pattern.

* is the most greedy wildcard there is, any amount of any characters
%d matches unsigned numeric values
%w is for single words
_________________
Discord: Shalimar#3679
Reply with quote
miegorengman
Beginner


Joined: 05 Sep 2008
Posts: 19

PostPosted: Sun Jun 12, 2022 4:37 am   
 
thanks again.

I am now working on the output side of this program and %pop is really nice, but I have just realize that I am sending 423 to the mud instead of read 423. So my thought is I need to include read in what the trigger is saving to the list, or I need to somehow %concat read and %pop (unreadnotes)

In hopes of concatenate read and 423 i tried the following. The fire but do not compile:

Code:
#var unreadnotes %additem (%concat ("read", %1),@unreadnotes)
#var unreadnotes %additem (%exec("%concat ("read", %1)"),@unreadnotes)


I then tried to concatenate read and %pop (unreadnotes)

Code:
#send {read }%pop (unreadnotes)
#send read %pop (unreadnotes)
#send read|%pop (unreadnotes)
#EXEC {%concat("#send read ","%pop (unreadnotes)")}


in most cases the above results in an error parsing command. It seems that trying to combine %pop with other functions appears to make %pop no longer see what is in the brackets as a variable. I am not working in xml much, usually the GUI, and normally the variable appears as a green when %pop likes it, then turns to black when you have combined it with other funtions.

It seems reasonable that both methods should work, I just can't find enough bailing twine to cobble this together from the help files an forums.
Thanks again for all your help.
Reply with quote
shalimar
GURU


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

PostPosted: Sun Jun 12, 2022 6:05 am   
 
You seem to keep leaving a space between various functions and their opening parentheses.
This causes them to 'lose' the parameters you are trying to pass them.

Try:

#var unreadnotes %additem(%concat("read ", %1),@unreadnotes)
Or simply:
read %pop(unreadnotes)
_________________
Discord: Shalimar#3679
Reply with quote
miegorengman
Beginner


Joined: 05 Sep 2008
Posts: 19

PostPosted: Sun Jun 12, 2022 3:25 pm   
 
I stumbled on an answer to adding read and 423 together...it worky

Code:
#var unreadnotes %additem("read "%1,@unreadnotes)


if anyone has any ideas for mixing %pop with #send or something of that nature I think it will be very handy for something in the future :)


:EDIT

I posted this after midnight last night but for some reason I am only seeing it registering now...interesting


thank you shalimar, I will try to pay better attention to spacing, I appear to be adding it and leaving it out at random.
Reply with quote
miegorengman
Beginner


Joined: 05 Sep 2008
Posts: 19

PostPosted: Sun Jun 12, 2022 3:34 pm   
 
read %pop(unreadnotes) works great :)
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