 |
darmir Sorcerer

Joined: 10 Oct 2000 Posts: 706 Location: USA
|
Posted: Fri Dec 10, 2004 1:20 pm
Using a database for your shop inventory |
I haven't played much at all with databases so I am asking help from the Gurus on this one.
Currently I sell items from a push cart on my mud. What I would like to do is keep track of the items I sell and how much it was for. The push-cart is like a big container on my mud.
Here is the mud output for the cart held and not held.
<****** / ||||| > look in cart
cart (here) :
a ceramic jar filled with cream
24 freshly laid brown eggs
10 spoonful of creams
5 glob of clays
a pale-green bottle filled with milk
a pale-green bottle filled with milk
15 cut bundle of firewoods
a pale-green bottle filled with milk
The only difference between the cart being held or in the room is it changes from cart(here) to cart (carried)
Now what I would like to do is count the total items I have and then if I sell one of them. It would subtract if from the toal list and then the coin I get would be added to my market_profit variable.
To get the coin dollar amount the command is count.
Here is the output from that command:
<****** / ||||| > count
You begin searching through your belongings, taking a tally of your coin.
<****** / ||||| >
By your count, you have 141 coppers' worth in coin:
1 thin, ridged silver coin (left hand): 50 coppers
1 thin, ridged silver coin (a simple yellow leather pouch): 50 coppers
8 large, rounded bronze coins (a simple yellow leather pouch): 40 coppers
1 semicircular copper coin (a simple yellow leather pouch): 1 coppers
<****** / ||||| >
Really appreciate the help. I want to do this in a database if I could. |
|
_________________ Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian) |
|
|
 |
Danlo Magician

Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Fri Dec 10, 2004 4:10 pm |
Try this:
| Code: |
#trigger "CartInv" {cart ~(%w~) :} {#unvar ItemsInCart;#temp {%match(%line, "^$")} {#set CartInv 0} "" "exp"}
#cond {!%match(%line, "^$")} {#AddKey ItemsInCart {%eval(%db(@ItemsInCart,%line)+1)}} {loopexp|param=200}
|
Since you gave no example of the text you receive when you sell something from your cart, the adding-to-profit trigger requires a little touchup.
| Code: |
#trigger {You sell (*) for (%d) coppers.} {#AddKey ItemsInCart {%eval(%db(@ItemsInCart,"%1")-1)};#add Market_Profit {%2}}
|
|
|
|
|
 |
darmir Sorcerer

Joined: 10 Oct 2000 Posts: 706 Location: USA
|
Posted: Fri Dec 10, 2004 5:43 pm |
Danlo,
As for selling the wares in my cart. This is just done by:
1) getting the coin from the person purchasing it. I usually run the count command to see if they gave the the correct coin agreed upon.
2) Then i just get the item from my cart and give it to them.
Also I wanted this in a database not a data record. Please help. |
|
_________________ Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian) |
|
|
 |
darmir Sorcerer

Joined: 10 Oct 2000 Posts: 706 Location: USA
|
Posted: Mon Sep 12, 2005 1:58 am |
bump
|
|
_________________ Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian) |
|
|
 |
|
|
|