|
VgWizard14 Beginner
Joined: 30 Nov 2008 Posts: 14
|
Posted: Mon Apr 20, 2009 12:15 am
Database Problem - The code works sometimes? |
Let me start with the output.
Code: |
Prompt> list
a greying, auburn-haired woman has the following goods to trade:
01) an amber-dyed cap for 24 obsidian coins.
02) a draped amber linen loincloth for 73 obsidian coins.
03) a draped blue linen loincloth for 73 obsidian coins.
04) a draped grey linen loincloth for 73 obsidian coins.
05) a draped lavender linen loincloth for 73 obsidian coins.
[MORE]
06) a draped rose linen loincloth for 73 obsidian coins.
07) a embroidered amber linen shirt for 146 obsidian coins.
08) an embroidered black linen tunic for 232 obsidian coins.
09) a embroidered lavender linen shirt for 146 obsidian coins.
10) a embroidered rose linen shirt for 146 obsidian coins.
Prompt>
|
What I'm trying to do is create a database that captures the Merchant name, the name of the Item, and how much it costs. My main issue is that the same item can be sold from several different merchants, but the same merchant will never have the same item for sale twice (no double posts.)
Here's my code. It's a bit dirty as I'm just copy/pasting it from the window. The database is imaginatively named 'items'
Code: |
<Items>
^[a|an|the] &{item.Merchant} has the following goods to trade:$
#DBLOAD it
#echo @item.Merchant
#t+ EnableItems
-----
<EnableItems>
^*~) [a|an] &{item.Name} for &{item.BuyCost} obsidian coins.$
#IF (%QUERY((&Name = @item.Name) AND (&Merchant = @item.Merchant) ) = "") {
#NEW "" @item
#ECHO {New Item Added}}
|
As it is, it works, but only sporadically. I usually have to type list three or four times to get it to pick up all of the items. Additionally, it decides it wants to pick up entries that are already in the database.
What I want it to do is look through the database for Merchant X, see if Item Y is there. If It's not, add it. If it is there, leave it alone.
Thanks in advance! |
|
|
|
VgWizard14 Beginner
Joined: 30 Nov 2008 Posts: 14
|
Posted: Tue Apr 21, 2009 7:16 pm |
Update: I'm still having trouble with this, though I haven't had too much time to work on it, with finals approaching and all.. I'd really appreciate some input!
|
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Wed Apr 22, 2009 3:00 am |
Sorry, I've never messed with the databases, so I don't know it :(
|
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
VgWizard14 Beginner
Joined: 30 Nov 2008 Posts: 14
|
Posted: Tue Apr 28, 2009 11:42 pm |
Bump: Still having trouble. Anyone?
|
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Tue Apr 28, 2009 11:43 pm |
I'm surprised Vij or Fang hasn't taken this one up. They're both pretty good with this kinda thing. If you're still having trouble when I get around to writing my ident trigger to add items to a database I'll give ya a hand. But that could be awhile.
|
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Apr 29, 2009 3:20 pm |
I'm afraid that my knowledge of the zMUD database is second only to my knowledge of the rules of water polo. It's just not something I've ever had to use.
|
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: Wed Apr 29, 2009 7:25 pm |
Dang, and here I thought you'd written so much zScript that it would be cake :D
|
|
_________________ CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Wed Apr 29, 2009 9:44 pm |
Why not use DB vars anyway and make some cool alias which prints data on the screen, being nicely formatted and such?
Personally I have never really wanted to use Database either. I find Vars to be a lot nicer and also more scriptable.
Plus you don't have to keep an extra window open just for being able to do stuff. |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
VgWizard14 Beginner
Joined: 30 Nov 2008 Posts: 14
|
Posted: Wed Apr 29, 2009 11:41 pm |
The main goal is to make a searchable Database. Instead of entering every item by hand, I could simply have the script store it. That way, if I need item X, I will know that I can get it from Shop Y at the lowest cost.
I'm not sure how to have such an easy table using Vars. |
|
|
|
|
|