|
etali Beginner
Joined: 22 Aug 2003 Posts: 12 Location: United Kingdom
|
Posted: Sun Aug 31, 2003 11:52 pm
Trigger repeatedly on one line |
I'd like to strip out the number of batches of each herb in a pouch and put them in variables, so this would show up as...
pouch #99 contains 5 batches of wirren, 4 batches of jegga, 5 batches of wirren, 2 batches of harfy.
10 wirren (in total)
4 jegga
2 harfy
To test my triggers out (you may remember from the other post on here last week I'm still learning all this stuff) I have it at the moment just echoing the name of each herb seen.
#TRIGGER {%d batches of (%w)} {
#echo matches %%1
}
#wait 10000
#UNTRIGGER {%d batches of (%w)}
The problem is, this at the moment is only showing up the LAST herb listed - how can I get it to match each one as they show up?
Thanks in advance. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Sep 01, 2003 2:21 am |
You have two options. The first involves the use of the reparse state (which I'm not at all familiar with). The second--and likely much easier--is to replace %w with * or some other pattern that will match the rest of the text.
Option #2
#trigger {pouch #99 contains (*).} {#forall %replace("%1",", ","|") {#if ("%i" =~ "(%d) batches of ({wirren|jegga|harfy})") {#if (%iskey(%%2,@Herbs)) {#addkey Herbs %%2 %eval(%db(@Herbs,%%2) + %%1)} {#addkey Herbs %%2 %%1}}};#loopdb @Herbs {#show %val %key}} |
|
|
|
etali Beginner
Joined: 22 Aug 2003 Posts: 12 Location: United Kingdom
|
Posted: Mon Sep 01, 2003 10:26 am |
Thanks for your help! I think I understand the #forall bit - there can be up to six items in a pouch, and the description can go over more than one line, but if I add five commas, that should process them all shouldn't it?
It looks like you're putting the stuff in a database. I've created a database called herbs but nothing is appearing in it.
I've tried creating a variable called @herbs but that's not getting anything either.
If it's a DB I thought you'd have to go {#addkey herbs number=%%1 type=%%2} ?? The thing is that wouldn't put any duplicates into the same field and add them up....
Sorry if I sound silly but zMud is totally alien to me.
Thanks in advance. |
|
|
|
|
|
|
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
|
|