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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Jun 22, 2008 8:36 pm   

Proper Format For Placing (%w) (%d) and the like inside of String List Variables
 
I want to add the following to a string list var, then trigger off the variable, someone please let me know the proper way to encapsulate the (%w) and such into a string list used for this purpose.

(%w)'s blade barrier blocks *
(%w)'s Cyris luck makes * miss!
(%w) blocks *
(%w) parries *
(%w) wind wall blocks *
(%w) dodges *
(%w)'s Sword blazes blue white as the power of %w protects him!

All of that put into a string list named BlockMsgs...

And then I want something like this:
Code:
#TR {{@BlockMsgs}} {#3 rescue %1}


Basically, I've tried just putting them in as is, I've tried using the tilde to escape the parens, and then also the parens AND the percent signs, and now I'm lost. :)
I know this can be done, just need someone to tell me how. And yes, I need it kept in zScript, because not everyone I'm sharing it with understands and would be able to modify regex.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Jun 22, 2008 9:45 pm   
 
Best thing to do is not put the %w's in there in the first place. Everything after the %w and before the * can be placed in your block variable. Then do:

#TRIGGER {(%w) {@BlockMessages}} {#3 {rescue %1}}

Simple, and does what you need it to.

Charneus
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Mon Jun 23, 2008 12:28 am   
 
Except I cannot do that. Not ALL of the messages have the (%w) in the same place. Some are like this:
* DEVASTATES (%w) with

Etc Etc Etc...

I need it to be versatile enough that I can have the * and the (%w) anywhere with any combination of words.

Thats why the conundrum. :)
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Mon Jun 23, 2008 12:54 am   
 
Ok, I was reading the help files again and noticed something I missed before. This CANNOT be done after all. OOPS. Oh well, I'll just use a separate trigger for each of the messages and call it good. Thanks anyways.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Jun 23, 2008 4:05 am   
 
I'd love to have a link to that helpfile. Both ZMud and CMud are capable of using wildcards in stringlists, so either you are mistaken about what you are reading or needing to do, or the helpfile is wrong.
_________________
EDIT: I didn't like my old signature
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Mon Jun 23, 2008 6:18 am   
 
MattLofton wrote:
I'd love to have a link to that helpfile. Both ZMud and CMud are capable of using wildcards in stringlists, so either you are mistaken about what you are reading or needing to do, or the helpfile is wrong.


Well, its in the help file right under Pattern Matching:
{val1|val2|val3|...} match any of the specified strings can not use other wildcard inside this

Hum Drum. And since I was attempting to do it this way, just using a var to hold the values... though I did try it without the brackets and it STILL did not work.

So, if I'm doing it wrong, plz show me ;)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Jun 23, 2008 9:41 am   
 
It only changed very recently, the help file is out of date.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Mon Jun 23, 2008 2:27 pm   
 
So, if the help file is out of date... how do I do this in zMUD 7.21? :) Like I said, I've tried it both ways and no joy. It is probably something simple I'm missing, but meh.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Mon Jun 23, 2008 3:12 pm   
 
BTW, this CAN be done in CMUD. Just something to think about.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Jun 23, 2008 5:26 pm   
 
Change the messages in BlockMsgs variable to be regexes à la:
Code:
(?rescue:\a+)'s blade barrier blocks .*
...
...
(?rescue:\a+)'s Sword blazes blue white as the power of \a+ protects him!

Then change the trigger to:
Code:
#REGEX {(?:@BlockMsgs)} {#3 rescue @rescue}


We capture directly to the rescue variable because if we changed it to (\a+) we would have no way of knowing which %n to use
as the name to be rescued would be in %1 %2 %3 etc depending on which string matched
You could of course just do rescue %concat(%1,%2,%3,%4,%5,%6,%7)
as long as you updated the concat when changes are made to the BlockMsgs variable.

Overall though I think it better to just capture to a variable.


P.S. I'm really not sure if this needs to be a regex that's just how I tried it, you could always try with &varname format using #TR
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Mon Jun 23, 2008 6:13 pm   
 
*Tickles Dharkael*

You must have missed that I need this kept in zScript :)
I'm writing this for a group of players, and not all of them understand anything more than zScript.
This is the same reason I cannot do it in CMUD, I need it to be portable to the entire group, which means zMud since thats what everyone is using except myself and one other person (I have both Z and C, but not buying C yet).

Interestingly enough, the regex zmud shows for my zscript is exactly what Dharkael has, and it doesn't work. Someone care to explain THAT?
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Jun 23, 2008 6:59 pm   
 
It's for the reason Dharkael explained. Your pattern expands into this:

{(%w)'s blade barrier blocks *|(%w)'s Cyris luck makes * miss!|(%w) blocks *|(%w) parries *|(%w) wind wall blocks *|(%w) dodges *|(%w)'s Sword blazes blue white as the power of %w protects him!}

%1 only counts for the first one. %2 is the second one - Cyris' luck - and so on. Using his %concat(%1,...,%7) would probably work, but it's an awful way of doing it. Using a variable like he has would be better.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Mon Jun 23, 2008 7:07 pm   
 
In my experience you don't even need to concat them... Simply doing

%1%2%3%4%5%6%7%8%9%10 = blah

would do it.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Mon Jun 23, 2008 7:28 pm   
 
The problem that Ralgith is having is such that the trigger does not even fire.
So it never comes down to %concats or %n
I say now's a good time to help your friends understand the power of regexes.
They really only need to know 3 for this:
(?rescue:\a+) \a+ and .* , that couldn't be all that overwhelming Razz
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Mon Jun 23, 2008 7:32 pm   
 
While I dunno if the same workaround for cmud works in zmud or not but to get the wildcards to parse you can try %%string(@stringlist) in the pattern. This works in cmud, like I said not sure about zmud.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Jun 23, 2008 7:45 pm   
 
It won't work in zMUD - you can't call functions from trigger patterns in zMUD.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Mon Jun 23, 2008 10:49 pm   
 
Ok, so if I replace all of my (%w) with &Actor say... then it would work? That just seems too damned simple :P

@Dharkael: If you can teach that mass of idiots regex be my guest :) About 1/4 of them don't even understand zScript lol. Oh well. I'm probably just going to do it with regex and then every time someone finds another Msg that needs to be checked (3 types of msg, blocks, misses, and attacks) I'll add it, then update a hosted file somewhere for the Peons to download.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Jun 23, 2008 11:05 pm   
 
You could try just saying "use .* instead of *, \w+ instead of %w" and whatever else you think they're going to need. That's how I first learnt regex, actually, comparing someone's regexes to how they'd be done in zScript. Yes, zMUD - fun and educational Cool

And you can always upload to the package library, you know.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Jun 23, 2008 11:51 pm   
 
Well, this is interesting. The &varname and (wildcard) weirds up in a stringlist, but otherwise it works. I noticed that in a simple three-item stringlist pattern:

#trigger {(%w) test|test (%d)|test &%wtest}} {#SAY I fired: 1st - %1 2nd - %2 3rd - @test}

The trigger would fire on all obvious test cases, but the data was only ever captured for the last two cases and it put them in the wrong slot (case 2 ended up in %1, case 3 ended up in %2):

two test
I fired: 1st - 2nd - 3rd -
test 2
I fired: 1st - 2 2nd - 3rd -
test friend
I fired: 1st - 2nd - friend 3rd - friend
_________________
EDIT: I didn't like my old signature
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Tue Jun 24, 2008 5:03 pm   
 
And no Fang, zMUD doesn't have a package library *tease*
Maybe when I buy CMUD...
But since I'm not working right now that isn't gonna happen.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Jun 24, 2008 5:54 pm   
 
Gah. This forum needs to have a different colour scheme or something, 'cause I'm constantly making that mistake :(
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Tue Jun 24, 2008 7:09 pm   
 
You're not the only one ;)
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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