Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: 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)
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: 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}}
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: 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)
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: 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)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net