![](templates/Classic/images/spacer.gif) |
ToyMage Apprentice
Joined: 01 Sep 2005 Posts: 120
|
Posted: Tue Jun 11, 2019 11:17 am
Help on Trigger capturing.. |
please help... hi hi, my mud has the following output,
========
This quest is to hunt down 'The cloaker' (Underdark), 'an oversized
dragon' (Cloudy Mountain) and 'a xaren' (Underdark). Kill all three
to claim 52000 gold, 300 exp and 30 kp.
========
1) I was hoping to capture:
a) 'The cloaker' as @mob1,
b) 'an oversized winged dragon' as @mob2
c) 'a xaren' as @mob3
However most of the time @mob2 is captured wrongly because carriage return... would anyone know how to best capture it?
I was wondering if I can combine both lines first and than extracting the mob1, mob2 and mob3?
2) how can i remove "a" "an" and "The" from the 3 variables?
thanks in advance..... many appreciation... |
|
|
![](templates/Classic/images/spacer.gif) |
shalimar GURU
![](images/avatars/114658559147aeed8fee539.gif)
Joined: 04 Aug 2002 Posts: 4685 Location: Pensacola, FL, USA
|
Posted: Tue Jun 11, 2019 3:22 pm |
In this case, we have to append lines together with %concat.
Seeing as it spans several lines we need a multistate trigger.
We use %ends to see which line ends in a period, so we know when to actually test our results.
And the %match is used on the finished product, testing against a known pattern and setting variables (essentially a trigger in a function).
#TR {This quest is to hunt down} {questLine=%line}
#COND {*} {
questLine=%concat(@questLine, %line)
#IF (%ends(%line, ".")) {#CALL %match(@questLine, "This quest is to hunt down 'The cloaker' ~((*)~), 'an oversized dragon' ~((*)~) and 'a xaren' ~((*)~).", mob1, mob2, mob3)} {#STATE 1}
} {within|param=1} |
|
_________________ Discord: Shalimarwildcat |
|
|
![](templates/Classic/images/spacer.gif) |
ToyMage Apprentice
Joined: 01 Sep 2005 Posts: 120
|
Posted: Tue Jun 11, 2019 7:08 pm |
WOW SHALIMAR!! NICE!! works!!
Currently I'm using the below to remove the A, a, An, an, The, the? is there any nicer way?
*the below method causes some to be remove in correctly... "Santa Claus" became "Sant Claus"
Mob1=%REMOVE("A ",@Mob1)
Mob1=%REMOVE("a ",@Mob1)
Mob1=%REMOVE("An ",@Mob1)
Mob1=%REMOVE("an ",@Mob1)
Mob1=%REMOVE("The ",@Mob1)
Mob1=%REMOVE("the ",@Mob1)
Mob2=%REMOVE("A ",@Mob2)
Mob2=%REMOVE("a ",@Mob2)
Mob2=%REMOVE("An ",@Mob2)
Mob2=%REMOVE("an ",@Mob2)
Mob2=%REMOVE("The ",@Mob2)
Mob2=%REMOVE("the ",@Mob2)
Mob3=%REMOVE("A ",@Mob3)
Mob3=%REMOVE("a ",@Mob3)
Mob3=%REMOVE("An ",@Mob3)
Mob3=%REMOVE("an ",@Mob3)
Mob3=%REMOVE("The ",@Mob3)
Mob3=%REMOVE("the ",@Mob3) |
|
|
![](templates/Classic/images/spacer.gif) |
shalimar GURU
![](images/avatars/114658559147aeed8fee539.gif)
Joined: 04 Aug 2002 Posts: 4685 Location: Pensacola, FL, USA
|
Posted: Tue Jun 11, 2019 8:46 pm |
The issue here is that you are trying to remove whole words from a given string, without ensuring you are only working with whole words.
So... i am converting each variable string into an array of whole words (%replace), deleting the member we want (%delitem), then converting it back into a string (%replace).
#FORALL "a|A|an|An|the|The" {
mob1=%replace(%delitem(%i, %replace(%trim(@mob1), " ", "|")), "|", " ")
mob2=%replace(%delitem(%i, %replace(%trim(@mob2), " ", "|")), "|", " ")
mob3=%replace(%delitem(%i, %replace(%trim(@mob3), " ", "|")), "|", " ")
} |
|
_________________ Discord: Shalimarwildcat |
|
|
![](templates/Classic/images/spacer.gif) |
ToyMage Apprentice
Joined: 01 Sep 2005 Posts: 120
|
Posted: Wed Jun 12, 2019 6:47 am |
wow.. works perfectly...
although i didnt understand what is "%i" |
|
|
![](templates/Classic/images/spacer.gif) |
shalimar GURU
![](images/avatars/114658559147aeed8fee539.gif)
Joined: 04 Aug 2002 Posts: 4685 Location: Pensacola, FL, USA
|
Posted: Wed Jun 12, 2019 5:20 pm |
%i is the current iteration of the #FORALL loop
|
|
_________________ Discord: Shalimarwildcat |
|
|
![](templates/Classic/images/spacer.gif) |
ToyMage Apprentice
Joined: 01 Sep 2005 Posts: 120
|
Posted: Fri Jun 14, 2019 8:01 pm |
Ah.. understood. Thanks.. o am getting better
|
|
|
![](templates/Classic/images/spacer.gif) |
|
|
|
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
|
|