|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: Mon Apr 11, 2005 3:38 pm
removing a, an, the from mobnames |
This is the pattern i capture from the mud:
* tells you 'Seek (*) out somewhere in the vicinity'$
Some examples of output from the mud:
ex1: Questor tells you 'Seek a bat out somewhere in the vicinity'
ex2: Questor tells you 'Seek An ogre mage out somewhere in the vicinity'
ex3: Questor tells you 'Seek Archer out somewhere in the vicinity'
ex4: Questor tells you 'Seek Julia the Tinker out somewhere in the vicinity'
most of the a's an's and the's are not keywords, like in ex2, ogre and mage i wanna keep, but lose the a... but not all a's at beginning of all mobs as in ex3 Archer or all "a " as in ex4 "Julia "
what i have is an MXP trigger for [Target] <--- wanna plug keyword 1 into it, and then trigger keyword2,3,4 etc if 1 doesnt attack.
any ideas? |
|
|
|
DeReP Adept
Joined: 14 Jun 2003 Posts: 222 Location: Chile
|
Posted: Mon Apr 11, 2005 4:30 pm |
#TRIGGER {%w tells you 'Seek {a |An |the |}(*) out somewhere in the vicinity'} {#ADDITEM target %1}
This should add the new target to the @Target list
I am not sure bout the MXP thing couse I dont really know the script :D |
|
|
|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: Tue Apr 12, 2005 6:57 am |
this works for some but not all, like ex4: Julia the Tinker, wanna remove "the" from the middle.
Other examples:
A guardian of the light <- needa lose a, of, & the
A pair of disembodied eye <-- a & of
A prisoner in hell <-- a & in
A soul of an old man <-- a, of, & an
What im thinking i need is to store the name in a stringlist,
A|soul|of|an|old|man
then do a #DELITEM for all in @remove_words where
remove_words = a|an|of|the|etc|etc
that way it would leave soul|old|man
90% of the time the leftover keywords the 1st is a good keyword, i.e. soul
I'll have to code something else when 'soul' fails to set target to next item in that list.
so, ill prolly needa start with a %replace('A soul of an old man', " ", "|")
then a #forall @target {#if %ismember(%item(@targets,%i), @remove_words) {#DELNITEM @target %i}} ??? heh, that might work actually.... the more you look at something the easier it gets :P
trying that, or maybe it should be something else entirely.... any other ideas? |
|
|
|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: Tue Apr 12, 2005 9:33 am |
ok, came up with a solution, but it is slow....
The Administrator tells you 'Seek A Blob Of Blood And Guts out somewhere in the vicinity'
where %1 = A Blob Of Blood And Guts
quest_mob = %replace( %1, " ", |)
#LOOP 2 {
#LOOP %numitems( @quest_mob) {
#FORALL @remove_words {
this_word = %item( @quest_mob, %j)
this_remove_word = %k
#if ( @this_word == @this_remove_word) {
#show Deleting this_word: @this_word Deleting this_remove_word: @this_remove_word
#DELITEM quest_mob @this_remove_word
}
}
}
}
quest_mob = %replace( @quest_mob, |, " ")
leaves me with @quest_mob being "blob blood guts"
and when i "see" this mob it has [Target] at the end of the line...
which i have a trigger with "#SUB {~[<send "kqmob">TARGET</send>~]}" as the command
works fine, hadda put it all inside a #LOOP 2 so it would work correctly, my math is obviously all screwed up in the loops, but even in a single loop it seems rather slow... several seconds to process
any ideas, or a faster way? |
|
|
|
Maelstrom Apprentice
Joined: 10 Feb 2005 Posts: 158
|
Posted: Tue Apr 12, 2005 1:15 pm |
The list might get a little nasty but this should be much faster...
#ECHO %subregex("A guardian of the light","\bA |\bof |\bthe |\band |\ban","") |
|
|
|
DeReP Adept
Joined: 14 Jun 2003 Posts: 222 Location: Chile
|
Posted: Tue Apr 12, 2005 1:35 pm |
#TRIGGER {The Administrator tells you 'Seek (*) out somewhere in the vicinity'} {
#VAR quest_mob %replace(%1," ",|)
#FORALL @remove_words {#delitem quest_mob %i}
#VAR quest_mob %replace(@quest_mob,|," ")
}
That should do the same that you accomplish I think
At least it gave me the same result.
Now you needed some kind of script to discard a word if it didnt work as a keyword for the mob. In that case I wouldnt replace the "|" back to spaces, but keep it as a list and maybe do something like this:
#ALIAS kbomb {kbomb %item(@Quest_mob,1);#TEMP No_keyword {No one around by that name.} {#SHOW %pop(@Quest_mob) found no target;kbomb}
#TRIGGER {You successfully "kbombed"} {#SET No_keyword 0}
Obviously I assumed the failing of kbomb would show "No one around by that name" and it being succesfull "You successfully "kbombed"".
Now this would only work if you ditch the
#VAR quest_mob %replace(@quest_mob,|," ")
from the first trigger we made. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Tue Apr 12, 2005 9:27 pm |
Combining the two solutions and doing a small lookup in zMud results with
#TRIGGER {The Administrator tells you 'Seek (*) out somewhere in the vicinity'} {
#VAR quest_mob {%replace(%subregex("%1","\b(?:the|of|in|an|a)\b","")," ","|")}
#DELITEM quest_mob {}
#VAR quest_mob {%replace(@quest_mob,"|"," ")}
}
Tested with:
#ECHO The Administrator tells you 'Seek an ugly, old hag in the bag out somewhere in the vicinity' |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Maelstrom Apprentice
Joined: 10 Feb 2005 Posts: 158
|
Posted: Wed Apr 13, 2005 1:04 am |
Or, to further expand on Vijilante's
Sorry Vij I just couldn't help myself...
I am tending to like this one because the list is easy to read and also now we can make helper alias' to add/remove items from the list with ease...
Code: |
#VARIABLE WordFilter {A|a|the|of|in|an} {A|a|the|of|in|an}
#TRIGGER {The Administrator tells you 'Seek (*) out somewhere in the vicinity'} {
#VAR quest_mob {%subregex("%1","\b(?:<@WordFilter>) ","")}
} |
|
|
|
|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: Wed Apr 13, 2005 10:07 am |
Wow Maelstrom... that rules... it is EXACLY what i was looking for :)
guess i really should learn how to use regex and subregex, that's twice now someone has used it as a solution for me :P
:edit: Yup just tried it on:
The Administrator tells you 'Seek a humble priest out somewhere in the vicinity'
and my mxp sub as i clicked on [Target] sent k humble priest, worked great :) |
|
|
|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: Wed Apr 13, 2005 11:26 am |
BLAH!... just got one with a comma in it... need to strip those too :P
Saminga, prince of death
set it to Saminga, prince death
guess i can simply do a %replace for those though
quest_mob = %replace(@quest_mob, ",", "")
sets it to:
Saminga prince death
so no worries :) |
|
|
|
|
|
|
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
|
|