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: Mon May 05, 2008 1:15 pm   

Here's a Question of sorts...
 
Say I wanted to capture a piece of EQ, and that I decided to capture the full phrase of the EQ name. However, the key words to use the EQ is often pieces of the whole, not the whole itself...

a pair of beeswax ear plugs

Object 'beeswax wax ear plugs' is type trash, extra flags magic rot_death.
Weight is 0, value is 10000, level is 1.
The object is made of wax.

Key words are italicized.

the Staff of the Adept

Object 'staff of the adept' is type weapon, extra flags anti-good.
Weight is 10, value is 1500, level is 50.
The object is made of wood.
Weapon type is staff.
Damage is 5d6 (average 17).
Weapons flags: stun
Condition: perfect (100%)
Affects damage roll by 2.

I was thinking of how I could solve this, and I think I found it.

((?:The, A, Some) *)
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Mon May 05, 2008 2:19 pm   
 
That wouldn't account for the 'a pair of ' prefix then, would it?

Detecting the noun (with or without adjectives) isn't always a simple task. For example, try coding something to detect the noun in 'a ruby ring carved with flames,' and you'll find that you want to use ruby as the noun or maybe flames... Smile
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon May 05, 2008 2:53 pm   
 
That pattern means "The string 'The, A, Some' followed by any number of spaces". There's no need for the (?: ) in this case because you're not doing anything to the stuff it contains.

Really, what you want is something like this:

#trig {Object '(*)' is type (%w), extra flags (*).} {#var object %1;#var keywords %subregex(%subregex(%1,"of|the|a|some|pair")," +","|");#var type %2;#var flags %replace(%3," ","|")}

This way, words that are nothing to do with the item (of, the, a, some and pair in this case, but adding more is easy) are removed, and then spaces are replaced with |s to make a stringlist.

EDIT:
@larkin: yeah, noun detection is hard without a dictionary or something (the speed expense of which would probably make it not worth the hassle), but it doesn't need to be perfect. Getting rid of the guff words should be close enough.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon May 05, 2008 3:02 pm   
 
If, in the case that Larkin presents, the mud will recognize "ruby ring carved with flames", then yes, all you need to do is drop the article (a, an, the). You also need to drop the space after the article. I'm not an expert at regex, but I think this will do what you want:

(?:the |a |some )?(.*)

The second question mark can be dropped if you are certain every object name starts with an article.



wow, seriously ninja'd.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon May 05, 2008 3:17 pm   
 
It doesn't show up with the identification. I was using that to show you what the key words are normally like. I need it to capture useful words in a phrase like:


a pair of beeswax ear plugs

But to only capture beeswax ear plugs


or


the Staff of the Adept

But to only capture:

Staff Adept
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Mon May 05, 2008 4:42 pm   
 
Your regex would be something like (?:the|a|some|a pair of)(.+) in that case, adding any other article words/phrases as needed.

(My example wasn't specific to chamenas' MUD, but more my own, where 'ring' is the only noun that works and you want to avoid detecting 'ruby' as the noun. Smile )
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon May 05, 2008 4:47 pm   
 
(?:the|a|some|a pair of)(.+) won't work for "staff of the adept", though. My example should.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon May 05, 2008 5:37 pm   
 
Alright, it's just that what you posted looks confusing. And I want to be able to understand it so I can alter as needed. Also, your example required the identification line, that doesn't show up normally. I posted it so you could see some examples of what is used for keywords. The line that shows up the the single line otherwise known as the short.

Like... the Staff of the Adept

There's no Object is, or anything like that.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon May 05, 2008 5:56 pm   
 
Well, obviously the script is going to need to know when to do its thing and what text to do it on. My example just used what you'd given, it'll work with any input. The key line is this:

#var keywords %subregex(%subregex(%1,"of|the|a|some|pair")," +","|")

Which has two nested subregexes that it runs on whatever you pass to it. The first is %subregex(%1,"of|the|a|some|pair") which will simply remove the words in the list (because the parameter for what to replace it with is blank). The second is %subregex(...," +","|") which will replace spaces (including when there's more than one space together, because the previous subregex will cause a double-space where a word was removed) with bars | which makes a stringlist. Then it's saved in a variable.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon May 05, 2008 7:08 pm   
 
so my capture pattern would be? (*)? Because that's too open and will capture lots of things. I'd se \w+ bit the number of words can vary... Confused
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Mon May 05, 2008 7:10 pm   
 
What text are you actually triggering on? Is this a room description? Inventory listing? Or are you trying to trigger on the text you posted with the object description, which is what Fang based his initial trigger suggestion on? There has to be some initial indicator that you're going into this 'item capture' mode, basically.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon May 05, 2008 7:33 pm   
 
When I wear an item and remove an item I want them stored in variables

Current_helm
Last_helm

Current_leggings
Last_leggings

etc...

So the trigger text would be...


<1519/1519hp 876/876m 456/456mv 561cp 1449pq 927g/80s
[The Nordmaar Master Crafters' Shop] [N-NW-NE] 3:00am [Night Time]>
rem helm
You stop using a bull elephant leather helmet.

<1519/1519hp 876/876m 456/456mv 561cp 1449pq 927g/80s
[The Nordmaar Master Crafters' Shop] [N-NW-NE] 3:00am [Night Time]>
wear helm
You wear a bull elephant leather helmet on your head.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon May 05, 2008 8:08 pm   
 
Simple.

#trig {You {stop using|wear} (*) {.|on your}} {...}

Job done.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue May 06, 2008 1:15 am   
 
Well I need to separate them for different variables. One for using which is the last and one for wear (or wearing) which is current.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue May 06, 2008 1:22 am   
 
*shrug* So use two separate triggers. That should be easy. "You stop using (*) on your".
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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