|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon May 12, 2008 12:17 am
Alright, running through a string... couple of purposes |
This was mentioned before, but I wanted to make a whole thread for it. I really want to understand this for the many effects it can have. That is, I want to know how to take a string not in list format and have it run through each word.
For a bit more complexity, it can stop running through words once a certain thing happens.
For even more complexity, it can remove words that will obviously do nothing for it, particularly articles like "a" and "the"
Some examples...
Awhile back I wanted to do some complex stuff with a trigger set that would record what I was wearing currently, and the last item I was wearing. This would be neat for various purposes, the example I have however is merely one.
There is a place in my game in which you will go deaf on a certain event if not wearing an item called "a pair of beeswax ear plugs". However nice they are, that's their only purpose and I only wear them when I go to the place. I'm often made to go there for quests, a lot of actions for which I've automated. I'd like to have it automatically wear the ear plugs. But that's the easy part. The hard part is having the proper head piece being worn after I turn in the quest. I could make one for my current head piece, but then I would have to remember to change it whenever I got something new. Instead, I would like the client to remember what I was last wearing so that when I turn in the quest, it can put that on instead.
This isn't the head piece, but I don't actually have a good one right now. So here's another example of my point:
You stop using some bull elephant leather gloves.
some bull elephant leather gloves
^ is the short name for the item
Some bull elephant leather gloves lie here.
^ is the long name for the item
'bull elephant leather gloves'
^ are the keyword for them
The keywords are what is important, however, when I remove the piece, it captures the short. As you can see, for many items, the short and keywords are very similar, so if I caught "some bull elephant leather gloves", excluded "some" and ran through each word it would be reequipped. To avoid the wrong items being worn, I would actually like the algorithm to run like this:
Try whole string -> Try first word in string -> Try second word in string -> ... -> ...
For that first bit of complexity, when the item is worn, for efficiency, it would be nice if it stopped right there and didn't continue. For instance, when I put the gloves back on:
You wear some bull elephant leather gloves on your hands.
When that line came back up, after it sent the whole string "bull elephant leather gloves" (since some would be removed), that should match, the action should happen. But instead of then trying "bull", "elephant", "leather", "gloves", it would be nicer if it just took the wearing line and stopped.
So that's about all that I can think of. I'm looking for help in setting this up, and explanations so I can understand what's going on. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon May 12, 2008 1:02 am |
Your looking to try a brute force approach when you need finesse. What you want to do is capture the keyword when it is input with the wear or remove command, and record the item it relates to. Then you can coordinate a putting something back on.
Alternately you could use the sneaky method that should work for the mud codebase you are on. Try this at the command line:
Code: |
wear earplugs
wear 1. |
If that worked then you should be able to split the two commands up to the momentes when you need them. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon May 12, 2008 1:33 am |
wear bees
wear 1
You stop using a elephant leather helmet.
You wear a pair of beeswax ear plugs on your head.
<1269/1269hp 755/755m 376/376mv 27820tnl 331pq 191/377w 473g/826s
[The Grove of Healing] [U-NW-SW] 9:00am [Day Time] [Elvish]>
You do not have that item. |
|
|
|
Troublemag Wanderer
Joined: 14 Jul 2004 Posts: 83
|
Posted: Mon May 12, 2008 3:36 am |
Not wear 1, wear 1. The . is very important, at least in most code bases.
|
|
_________________ CMUDPro 3.22 |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon May 12, 2008 3:45 am |
<1269/1294hp 755/755m 376/376mv 27820tnl 331pq 191/377w 473g/826s
[The Great Tree] [NEWU-NW-NE] 7:00am [Day Time] [Elvish]>
wear bees
You stop using a elephant leather helmet.
You wear a pair of beeswax ear plugs on your head.
<1269/1269hp 755/755m 376/376mv 27820tnl 331pq 191/377w 473g/826s
[The Great Tree] [NEWU-NW-NE] 7:00am [Day Time] [Elvish]>
wear 1.
You do not have that item. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon May 12, 2008 6:36 am |
Chamenas you sure are confusing. Why would you try and "wear bull" or "wear elephant"? Are you going to wear a bull on your head? Those are just descriptions not the actual item.
a pair of bull elephant leather gloves
GLOVES are the item. It's just like when you refer to any item, thing, or person. If I have an ornate steel rapier, I don't try "wield ornate" I do "wield rapier", otherwise the Mud will come back and say "What are you retarded? I don't see that item!" or some nonsense. So why can't you just wear helmet or wear earplugs? For that matter, don't they have item numbers so you can just wear #####?
Quote: |
some bull elephant leather gloves
^ is the short name for the item
Some bull elephant leather gloves lie here.
^ is the long name for the item
'bull elephant leather gloves'
^ are the keyword for them |
Wouldn't the "short" name of the item be "gloves"?
Wouldn't the "long" descriptive name of the item be "bull elephant leather gloves"?
The keyword is gloves isn't it? I'm confused or you have a weird Mud. |
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Mon May 12, 2008 9:38 am |
I understand what he means, Oldguy.
He has a list of keywords that he can refer to the item by.
By short name, he means short description. By long name he actually means the dropped description (going by IRE crafting anyway) and by keyword, he means keywordS. Some of our (IRE) items have multiple keywords too. longcoat, coat. Pants, trousers. Etc. His mud just has more of them, and he would like to have a single trigger that wears what he was wearing before, regardless of what it was.
He doesn't want to have the item number of it stored in a variable, because it probably changes often.
He doesn't want to refer to it by 'gloves' first off, because 'elephant' is more specific, while 'gloves' might refer to several types in his inventory.
The first thing I would do, Chamenas, is turn the string into a stringlist. I'm going to use the old text format for displaying settings because I'm not confident with creating the xml from memory yet.
Code: |
#TR {You stop using a (*).} {keywords={%replace(%1," ","|")}}
Then:
#TR {Pattern for quest has been turned in, indicating you want to go back to normal clothing.} {
keywordStep=1
wear %item(@keywords, @keywordStep)
#ADD keywordStep 1
#T+ autoRewear}
#COND {} {#T- autoRewear;#SAY -- AutoRewear timed out, turning off triggers --} {wait|param=10000}
#CLASS autoRewear
#TR {You do not have that item.} {wear %item(@keywords, @keywordStep;#ADD keywordStep 1}
#TR {You wear a} {#T- autoRewear;#SAY -- Item reworn --}
#CLASS 0 |
So there. No matter what it was you were wearing when you (presuming with a trigger) wore the beeswax earplugs automatically, when you turn in the quest, it will wear the original item.
-------------------
Oh, if you want to have a list of words like 'some' 'at' 'the' etc to exclude..
#FORALL @wordstoExclude {#DELI @keywords %i}
Its a bit of a brute force approach, but so simple.. |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon May 12, 2008 1:04 pm |
I'll play around with it later, class is about to start and I should focus on that.
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon May 12, 2008 5:39 pm |
Well whatever. That's not the same thing. Glad it's all worked out though.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon May 12, 2008 6:44 pm |
Well I don't know if it has, still have to test it. In response to what you said, the most unique identifier that any item has is all of its keywords at once, so, for the gloves:
'bull elephant leather gloves'
that string would be the most unique ID
Another similar item might be:
'bull elephant leather helmet'
using bull, elephant, or leather will mean it checks for the first item with that keyword (you can type 2.leather, 3.leather, etc... in order to get other things with the same keyword.
In theory gloves and helmet are unique ids in this scenario, but not always. The most unique ID is the entire string name. The problem is that the short does not always have all of the keywords.
' |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon May 12, 2008 6:55 pm |
Right gotcha. It's just most muds I have played don't let you use something like that.
|
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Mon May 12, 2008 10:49 pm |
Hm. So you don't really want to try each word individually, you want to try the whole string and then if it fails start removing words that from it until it works? Beginning of course with words that are most likely to be non-keywords, such as 'some'?
I'm heading out for a few hours, but while I'm off if you can, please help by confirming this, or if I still have it wrong, correcting me. Then I'll have another shot at it.
At this stage the basis of what I suggested should still work, the only difference is figuring out how and what to remove from the short description.
I have two more requests, actually:
1st: the message when you "You stop using a elephant leather helmet."
Is the underlined part always the full list of keywords that form the most unique ID?
2nd: If the answer to the first is no, please post a list of all the short/wear/remove descs you can find in your inventory, as we need to try and figure out a pattern to it. If there is a patern, then the solution is fairly easy. If there is no pattern, then its a matter of creating a big list of non-keywords and checking for all of them every time. |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon May 12, 2008 11:39 pm |
Why don't I just quote my first response since this part got ignored.
Quote: |
Your looking to try a brute force approach when you need finesse. What you want to do is capture the keyword when it is input with the wear or remove command, and record the item it relates to. Then you can coordinate a putting something back on. |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Tue May 13, 2008 3:16 am |
Shhh! Let us catch up to you at our own pace... gracefully. No one likes an 'I told you so'
To be honest, it didn't get entirely ignored: I used your advice in my suggestion, and captured the keywords from that trigger as you suggested, with:
#TR {You stop using a (*).} {keywords={%replace(%1," ","|")}}
I just didn't understand that he can do "wear <entire keyword string>" hence turning the string into a list of keywords.
So how about:
Code: |
#TR {You stop using a (*).} {wasWearing={%1}}
#TR {Quest handed in.} {wear @wasWearing} |
Any reason why that won't work, Chamenas? |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Tue May 13, 2008 4:34 am |
Vijilante wrote: |
Why don't I just quote my first response since this part got ignored.
Quote: |
Your looking to try a brute force approach when you need finesse. What you want to do is capture the keyword when it is input with the wear or remove command, and record the item it relates to. Then you can coordinate a putting something back on. |
|
I caught it, but after your experiment didn't work, I didn't know where to go. I understand mine is the brute force methods, but it's the only thing I can think of right now. |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Tue May 13, 2008 5:42 am |
#TRIGGER {^You stop using a (*).} {#var bruteitem %1;#var bruteforce %replace(%1," ","|")}
#ALIAS wearold {#T+ "WearTrig";wear %replace(@bruteforce,"|"," ")}
#TRIGGER "WearTrig" {^You do not have that item.} {#CALL %pop(bruteforce);wear %replace(@bruteforce,"|"," ")}
#TRIGGER {^You wear *} {#addkey wearequip @bruteitem @bruteforce;bruteforce="";bruteitem="";#T- "WearTrig"}
Tested, and I'm sure you get the idea. What it's going to do is take the variable in "You stop using a (*)" and places it untouched in the bruteitem variable and modified to a stinglist in the bruteforce variable. Then, when you're ready to wear it again, type "wearold" and it'll run wear @bruteforce. If that fails, it'll remove the first word in the list and try again with the string. Example:
You stop using a some elephant bull gloves. -> "some elephant bull gloves" is stored into bruteitem. some|elephant|bull|gloves is stored into bruteforce.
You type "wearold", and it activates the WearTrig. It'll first try to wear "some elephant bull gloves." If that fails, it'll return whatever message (in this case, "You do not have that item.") Bruteforce then becomes elephant|bull|gloves. Next, it'll try to wear elephant bull gloves. This works, so a database is created called "wearequip." In that database, the "some elephant bull gloves" will have a value of "elephant bull gloves." You can use this database in the future to recognize what you took off and what the keywords are to wearing it again.
Hope this helps, and if you need more understanding, just let me know.
Charneus |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed May 14, 2008 4:15 pm |
Well, I tried using your suggestions to edit what I already have just for the recording part. But not everything is getting recorded. So here's the script:
Code: |
#regex grab_helm_cur {^You wear (?:a|the|some|an) (.*) (on|about|in) your (.*).$}
{
#say %1
#say %2
#say %3
#switch (%3)
"head" {cur_helm=%1;slot="head"}
"left finger" {cur_ringl=%1;slot="left finger"}
"right finger" {cur_ring=%1;slot="right finger"}
"left wrist" {cur_bracel=%1;slot="left wrist"}
"right wrist" {cur_bracer=%1;slot="right wrist"}
"neck" {#IF (@cur_neck1!="") {cur_neck1=%1;slot="neck1"} {cur_neck2=%1;slot="neck2"}}
"torso" {#IF (%3="on") {cur_torso=%1;slot="torso"} {cur_body=%1;slot="body"}}
"legs" {cur_leg=%1;slot="leg"}
"feet" {cur_feet=%1;slot="feet"}
"hands" {cur_hand=%1;slot="hand"}
"arms" {cur_arm=%1;slot="arms"}
"shield" {cur_shield=%1;slot="shield"}
"hand" {cur_held=%1;slot="held"}
#switch (@slot)
"head" {last_helm=@removed}
"left finger" {last_ringl=@removed}
"right finger" {last_ringr=@removed}
"left wrist" {last_bracel=@removed}
"right wrist" {last_bracer=@removed}
"neck1" {last_neck1=@removed}
"neck2" {last_neck2=@removed}
"torso" {last_torso=@removed}
"legs" {last_leg=@removed}
"feet" {last_feet=@removed}
"hands" {last_hand=@removed}
"arms" {last_arm=@removed}
"shield" {last_shield=@removed}
"hand" {last_held=@removed}
"body" {last_body=@removed}
} {General Triggers|EQ}
#regex grab_helm_last {^You stop using (?:a|the|some) (.*)\.$} {removed=%1;#say @removed} {General Triggers|EQ}
#al EQ_show {
#say @cur_helm
#say @cur_ringl
#say @cur_ringr
#say @cur_bracel
#say @cur_bracer
#say @cur_neck1
#say @cur_neck2
#say @cur_leg
#say @cur_feet
#say @cur_hand
#say @cur_arm
#say @cur_shield
#say @cur_held } {General Triggers|General Aliases}
|
The alias is important for seeing how I know certain values are missing. Here's some I/O, I deleted all the prompts and unnecessary information:
You wear an ice ring on your left finger.
ice ring
on
left finger
You wear an ice ring on your right finger.
ice ring
on
right finger
You wear the Amulet of Kwainin around your neck.
You wear the Amulet of Kwainin around your neck.
You stop using a bull elephant leather tunic.
bull elephant leather tunic
You wear a bull elephant leather tunic on your torso.
bull elephant leather tunic
on
torso
You stop using a pair of beeswax ear plugs.
pair of beeswax ear plugs
You wear a bull elephant leather helmet on your head.
bull elephant leather helmet
on
head
You stop using a MacAllen clan kilt.
MacAllen clan kilt
You wear a MacAllen clan kilt on your legs.
MacAllen clan kilt
on
legs
You stop using some bull elephant leather boots.
bull elephant leather boots
You wear some bull elephant leather boots on your feet.
bull elephant leather boots
on
feet
You stop using some bull elephant leather gloves.
bull elephant leather gloves
You wear some bull elephant leather gloves on your hands.
bull elephant leather gloves
on
hands
You stop using some bull elephant leather sleeves.
bull elephant leather sleeves
You wear some bull elephant leather sleeves on your arms.
bull elephant leather sleeves
on
arms
You stop using a skeletal shield.
skeletal shield
You wear a skeletal shield as a shield.
You stop using a MacAllen clan shoulder wrap.
MacAllen clan shoulder wrap
You wear a MacAllen clan shoulder wrap about your torso.
MacAllen clan shoulder wrap
about
torso
You stop using a jeweled bracer.
jeweled bracer
You stop using a jeweled bracer.
jeweled bracer
You wear a jeweled bracer around your left wrist.
You wear a jeweled bracer around your right wrist.
You hold a knight doll in your hand.
bull elephant leather helmet
ice ring
EQ_show
MacAllen clan kilt
bull elephant leather boots
bull elephant leather gloves
bull elephant leather sleeves
You stop using the Amulet of Kwainin.
Amulet of Kwainin
You stop using the Amulet of Kwainin.
Amulet of Kwainin
You wear the Amulet of Kwainin around your neck.
You wear the Amulet of Kwainin around your neck.
EQ_show
bull elephant leather helmet
ice ring
On many of the items it doesn't see, it clearly shows it recording upon the triggering, so I'm not sure what's going on.
MacAllen clan kilt
bull elephant leather boots
bull elephant leather gloves
bull elephant leather sleeves |
|
|
|
Troublemag Wanderer
Joined: 14 Jul 2004 Posts: 83
|
Posted: Wed May 14, 2008 4:21 pm |
First, you don't have "around" in your initial trigger. Second, you don't have anything set up to match either the shield or the held item.
|
|
_________________ CMUDPro 3.22 |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed May 14, 2008 4:41 pm |
Troublemag wrote: |
First, you don't have "around" in your initial trigger. Second, you don't have anything set up to match either the shield or the held item. |
That's what the if statements are for:
"torso" {#IF (%3="on") {cur_torso=%1;slot="torso"} {cur_body=%1;slot="body"}}
accounts for about the body, if it's about then %3 won't equal "on" on is only used when you put a tunic on.
For the held, when you hold something you hold it in your "hand" not wear it on your "hands" so hand should work. Edit: Nope, didn't forget "in" so I still don't see why it won't work.
And the pattern has about, which is what's needed for around the body:
{^You wear (?:a|the|some|an) (.*) (on|about|in) your (.*).$}
You wear a MacAllen clan shoulder wrap about your torso.
That doesn't, however, explain why so many other things are having issues. |
|
|
|
Troublemag Wanderer
Joined: 14 Jul 2004 Posts: 83
|
Posted: Wed May 14, 2008 8:14 pm |
chamenas wrote: |
You wear the Amulet of Kwainin around your neck.
You wear the Amulet of Kwainin around your neck.
You wear a jeweled bracer around your left wrist.
You wear a jeweled bracer around your right wrist.
You hold a knight doll in your hand.
|
If you don't have "around" or "hold" in your regex pattern, it will not pick up the examples I've quoted. The pattern will not match and your #If statements will never be used. |
|
_________________ CMUDPro 3.22 |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed May 14, 2008 10:18 pm |
Troublemag wrote: |
chamenas wrote: |
You wear the Amulet of Kwainin around your neck.
You wear the Amulet of Kwainin around your neck.
You wear a jeweled bracer around your left wrist.
You wear a jeweled bracer around your right wrist.
You hold a knight doll in your hand.
|
If you don't have "around" or "hold" in your regex pattern, it will not pick up the examples I've quoted. The pattern will not match and your #If statements will never be used. |
hahaha
I feel like an... well you know :P
I miss those little details, give me a minute to fix those and see how it goes. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Wed May 14, 2008 10:22 pm |
Alright, so here's what recorded:
bull elephant leather helmet
ice ring
jeweled bracer
jeweled bracer
Amulet of Kwainin
MacAllen clan kilt
bull elephant leather boots
bull elephant leather gloves
bull elephant leather sleeves
knight doll
It seems that my neck2 isn't working. Also, though the right and left bracer is working, left and right ring seem to have problems. It doesnt see the shoulder wrap or the tunic, which suggests something with those if statements. I'll look into them after my homework, but maybe someone can find out what's wrong faster and teach me something. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 2:01 pm |
So, here's the output and here's the result:
MUD Output wrote: |
rem ice
You stop using an ice ring.
<1674/1674hp 1088/1078m 456/456mv 641cp 1296pq 2090g/157s
[Cliath's Shrine Room] [EW] 8:00pm [Dusk]>
rem ice
You stop using an ice ring.
<1674/1674hp 1088/1068m 456/456mv 641cp 1296pq 2090g/157s
[Cliath's Shrine Room] [EW] 8:00pm [Dusk]>
eq
You are using:
<used as light> (Glowing) the Sceptre of Might
<worn on finger> (nothing)
<worn on finger> (nothing)
<worn around neck> (Blue Aura) (Glowing) the Amulet of Kwainin
<worn around neck> (Blue Aura) (Glowing) the Amulet of Kwainin
<worn on torso> (Glowing) a bull elephant leather tunic
<worn on head> (Glowing) a bull elephant leather helmet
<worn on legs> (Glowing) a MacAllen clan kilt
<worn on feet> (Glowing) some bull elephant leather boots
<worn on hands> (Glowing) some bull elephant leather gloves
<worn on arms> (Glowing) some bull elephant leather sleeves
<worn as shield> a skeletal shield
<worn about body> (Glowing) a MacAllen clan shoulder wrap
<worn about waist> (nothing)
<worn around wrist> (Glowing) a finely crafted mithril bracer
<worn around wrist> (Glowing) a finely crafted mithril bracer
<wielded> the Staff of the Adept
<held> (nothing)
<floating nearby> (Glowing) a small jade dragon
<sheathed> (Glowing) (Humming) a flaming dagger
<1674/1674hp 1088/1068m 456/456mv 641cp 1296pq 2090g/157s
[Cliath's Shrine Room] [EW] 8:00pm [Dusk]>
Kristof says in a deep voice 'Morning.'
<1674/1674hp 1088/1068m 456/456mv 641cp 1296pq 2090g/157s
[Cliath's Shrine Room] [EW] 8:00pm [Dusk]>
rem brace
rem brace
You stop using a finely crafted mithril bracer.
finely crafted mithril bracer
<1674/1674hp 1088/1043m 456/456mv 641cp 1296pq 2090g/157s
[Cliath's Shrine Room] [EW] 8:00pm [Dusk]>
You stop using a finely crafted mithril bracer.
finely crafted mithril bracer
<1674/1674hp 1088/1018m 456/456mv 641cp 1296pq 2090g/157s
[Cliath's Shrine Room] [EW] 8:00pm [Dusk]>
wear ice
You wear an ice ring on your left finger.
ice ring
on
left finger
<1674/1674hp 1088/1028m 456/456mv 641cp 1296pq 2090g/157s
[Cliath's Shrine Room] [EW] 8:00pm [Dusk]>
wear ice
You wear an ice ring on your right finger.
ice ring
on
right finger
<1674/1674hp 1088/1038m 456/456mv 641cp 1296pq 2090g/157s
[Cliath's Shrine Room] [EW] 8:00pm [Dusk]>
wear brace
You wear a finely crafted mithril bracer around your left wrist.
finely crafted mithril bracer
around
left wrist
<1674/1674hp 1088/1063m 456/456mv 641cp 1296pq 2090g/157s
[Cliath's Shrine Room] [EW] 8:00pm [Dusk]>
wear brace
You wear a finely crafted mithril bracer around your right wrist.
finely crafted mithril bracer
around
right wrist
<1674/1674hp 1063/1088m 456/456mv 641cp 1296pq 2090g/157s
[Cliath's Shrine Room] [EW] 8:30pm [Dusk]>
bull elephant leather helmet
ice ring
finely crafted mithril bracer
finely crafted mithril bracer
Amulet of Kwainin
MacAllen clan kilt
bull elephant leather boots
bull elephant leather gloves
bull elephant leather sleeves
glittering white stone
|
Code: |
#regex grab_helm_cur {^You (?:wear|hold) (?:a|the|some|an) (.*) (on|about|in|around) your (.*).$}
{
#say %1
#say %2
#say %3
#switch (%3)
"head" {cur_helm=%1;slot="head"}
"left finger" {cur_ringl=%1;slot="left finger"}
"right finger" {cur_ring=%1;slot="right finger"}
"left wrist" {cur_bracel=%1;slot="left wrist"}
"right wrist" {cur_bracer=%1;slot="right wrist"}
"neck" {#IF (@cur_neck1!="") {cur_neck1=%1;slot="neck1"} {cur_neck2=%1;slot="neck2"}}
"torso" {#IF (%3="on") {cur_torso=%1;slot="torso"} {cur_body=%1;slot="body"}}
"legs" {cur_leg=%1;slot="leg"}
"feet" {cur_feet=%1;slot="feet"}
"hands" {cur_hand=%1;slot="hand"}
"arms" {cur_arm=%1;slot="arms"}
"shield" {cur_shield=%1;slot="shield"}
"hand" {cur_held=%1;slot="held"}
#switch (@slot)
"head" {last_helm=@removed}
"left finger" {last_ringl=@removed}
"right finger" {last_ringr=@removed}
"left wrist" {last_bracel=@removed}
"right wrist" {last_bracer=@removed}
"neck1" {last_neck1=@removed}
"neck2" {last_neck2=@removed}
"torso" {last_torso=@removed}
"legs" {last_leg=@removed}
"feet" {last_feet=@removed}
"hands" {last_hand=@removed}
"arms" {last_arm=@removed}
"shield" {last_shield=@removed}
"hand" {last_held=@removed}
"body" {last_body=@removed}
} {General Triggers|EQ}
|
This time I didn't remove anything from the output so that there cannot be a lack of information. I find it odd that the bracers work and the rings don't. I understand now why the shield and neck won't work. (Well the neck is still somewhat confusing) |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 3:19 pm |
Trying to apply these concepts elsewhere to practice, doing it with my bed variable but I have an issue:
Code: |
#REGEX sleep {^You go to sleep(?: on a)?( .*)?\.$} {posn=sleep
bed={%replace(%1," ","|")}
#FORALL @commons {#DELI @bed %i} } {General Triggers}
#var commons {a|an|and|the|of|some|pair} _nodef {General Variables}
|
You go to sleep on a pile of pillows and blankets.
Bed: |pile|of|pillows|and|blankets
As you can see, it puts an | in the first spot, which I think is stopping it from making a string list, and this it's not deleting the items it should. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun May 18, 2008 5:15 pm |
#$!@# !@#$^& #@! %^&*& #$^&. It is doing exactly what you have asked for. The initial space is being replaced by a pipe with every other space. That initial space is there because that is what your pattern says to capture into %1. I am not giving you the solution for this one, just telling you were to look.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
|
|