 |
Churlant Novice
Joined: 17 Oct 2002 Posts: 44 Location: USA
|
Posted: Thu Feb 12, 2004 1:00 pm
Capture & Sell Trigger |
I've been puzzling this and thought this would be a good place to ask about a trigger set I want...
This is what I want to do - capture keywords on looted equipment and shortly after sell each in a shop. The catch is I would need to recognize the first 4+ letter word in the name as I lift it off a corpse, because words like 'a, an, the' etc would not necessarily be keywords. So the trigger catches the first 4+ letter word into a list and then sells each item on an echo command, or some such.
Suggestions? |
|
|
|
 |
megamog75 Enchanter

Joined: 20 Nov 2002 Posts: 627 Location: USA
|
Posted: Thu Feb 12, 2004 2:43 pm |
please give some wxamples so it is easier for someone to help you:
example:
You get a black potion from the corpse. |
|
|
|
 |
Churlant Novice
Joined: 17 Oct 2002 Posts: 44 Location: USA
|
Posted: Thu Feb 12, 2004 2:51 pm |
That is almost exactly it. A very recent example would be:
You get the small green dagger from the burned corpse of the soldier.
The 'you get' beginning is standard. The third word can be anything from 'the' to 'an' or 'a' or even a full key word. 'Small' here would be the word I'm interested in capturing. So really the first word that is more than 3 characters long is most likely to be one of the object keywords. |
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Feb 12, 2004 5:49 pm |
#TR {^You get (*)} {#PRI {#VAR get1 {%replace( "%1", ",", "")};#VAR get2 "";#LOOP %numwords( @get1),1 {#IF (%len( %word( @get1, %i)) > 4) {#VAR get2 %word( @get1, %i)}};#VAR loot %additem( @get2, @loot)}}
Because variables are easily overwritten, it's easier to find the last word meeting a condition than the first word. However, by looping backwards through a string, the last word checked will actually be the first word of the string. |
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Thu Feb 12, 2004 11:27 pm |
Lightbulb forgot to narrow the captured potion of the trigger down to just the item description, minor change. Also tagged the end of line with $, you can remove the beginning (^) and end ($) of line marks if needed.
#TR {^You get (*) from the * corpse *.$} {#PRI {#VAR get1 {%replace( "%1", ",", "")};#VAR get2 "";#LOOP %numwords( @get1),1 {#IF (%len( %word( @get1, %i)) > 4) {#VAR get2 %word( @get1, %i)}};#VAR loot %additem( @get2, @loot)}} |
|
|
|
 |
|
|
|