|
Amfitrion Wanderer
Joined: 29 Sep 2001 Posts: 75 Location: Israel
|
Posted: Tue Oct 29, 2002 12:58 am
substitute |
Suppose I get a following line:
You have 20 apples and 30 cherries.
I have a trigger that:
#trigger {You have &apples apples and &cherries cherries.} {}
In addition, I get another line:
You have 10 dollars.
Which I capture with:
#trigger {You have &dollars dollars.}
This was the introduction.
The question is, how to add to the apples and cherries line the dollar ammount.
I want to keep the original line (not to change it or fake it with subs), and to add to it the dollar ammount, like this:
"You have 20 apples and 30 cherries. (20 dollars)"
Thank you.
- Amfitrion. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Oct 29, 2002 1:28 am |
quote:
Suppose I get a following line:
You have 20 apples and 30 cherries.
I have a trigger that:
#trigger {You have &apples apples and &cherries cherries.} {}
In addition, I get another line:
You have 10 dollars.
Which I capture with:
#trigger {You have &dollars dollars.}
This was the introduction.
The question is, how to add to the apples and cherries line the dollar ammount.
I want to keep the original line (not to change it or fake it with subs), and to add to it the dollar ammount, like this:
"You have 20 apples and 30 cherries. (20 dollars)"
Thank you.
- Amfitrion.
If you already know the value, you can use a data record or stringlist to do some lookups:
#trigger {You have (%d) ({@Items.list}) and (%d) ({@Items.list})} {#Addkey Items %2 %1;#addkey Items %4 %3;#sub {You have %1 %2 and %3 %4. ~(%eval((%db(@Items,%2) * %db(@Items,%2"price")) + (%db(@Items,%4) * %db(@Items,%4"price"))~)}}
That might be a little screwed up, but basically it's taking &apples and &oranges and putting them in the appropriate record key (this is how many you have). It's then multiplying each value by whatever unit price each item is worth. finally, it's adding the final price for all items together to get your (20 dollars).
li'l shmoe of Dragon's Gate MUD |
|
|
|
Amfitrion Wanderer
Joined: 29 Sep 2001 Posts: 75 Location: Israel
|
Posted: Tue Oct 29, 2002 10:46 pm |
No no no. The question is how to put it all in a line, so when zmud receives a "You have 20 apples and 30 cherries." line, it will add to the end of this line something else. The problem is adding stuff to the end of the line I get from the mud, not calculating values.
- Amfitrion. |
|
|
|
Lalaynya Wanderer
Joined: 23 Aug 2002 Posts: 96
|
Posted: Tue Oct 29, 2002 11:44 pm |
quote:
No no no. The question is how to put it all in a line, so when zmud receives a "You have 20 apples and 30 cherries." line, it will add to the end of this line something else. The problem is adding stuff to the end of the line I get from the mud, not calculating values.
- Amfitrion.
In the trigger for the apples and cherries, add this line:
#SUB %trigger ~(@dollars dollars~)
That should give you what you want. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Oct 29, 2002 11:54 pm |
quote:
#trigger {You have (%d) ({@Items.list}) and (%d) ({@Items.list})} {#Addkey Items %2 %1;#addkey Items %4 %3;#sub {You have %1 %2 and %3 %4. ~(%eval((%db(@Items,%2) * %db(@Items,%2"price")) + (%db(@Items,%4) * %db(@Items,%4"price"))~)}}
Should read a bit closer sometimes. You HAVE to use #SUBSTITUTE or a similar command/function to change the output from the MUD unless you can get the coders of that MUD to change it on their end.
li'l shmoe of Dragon's Gate MUD |
|
|
|
|
|
|
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
|
|