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
Dorrin
Novice


Joined: 08 Aug 2002
Posts: 41

PostPosted: Sun Mar 09, 2003 9:56 am   

database query problems
 
I don't know if it's just because I'm tired, but I can't figure this out. I'm trying to query a database before writing a new record to it to avoid duplicate entries, but it's not working for some reason (probably something entirely simple).

Here's the output as generated by the MUD:

You study a dark cylindrical cap.
Object 'dark cylindrical cap' is type armor, usable by all.
Wear Location: take head
Weight is 1, value is 50, level is 91.
Armor class is 21 pierce, 21 bash, 21 slash, and 21 vs. magic.
Affects stamina by 37.
Affects hp by 38.
Affects wisdom by 1.
Affects intelligence by 1


These are the triggers I'm using:

#TRIGGER {You study (*).} {#VARIABLE ItemName "%1";#ADDKEY Item {Name="%1"}} "eqdb"
#TRIGGER {Object '(*)' is type &{Item.kind}, usable by &{Item.users}.} {#VARIABLE ItemKeywords "%1";#ADDKEY item {Keywords="%1"}} "eqdb"
#TRIGGER {Wear Location: take &Item.wear} {} "eqdb"
#TRIGGER {Weight is &Item.weight, value is &Item.cost, level is (%d).} {#VARIABLE ItemLevel "%3";#ADDKEY Item {Level = "%3"}} "eqdb"
#TRIGGER {Armor class is &{Item.armorp} pierce, &{Item.armorb} bash, &{Item.armors} slash, and &{Item.armorm} vs. magic.} {} "eqdb"
#TRIGGER {Affects stamina by &{Item.StamBonus}.} {} "eqdb"
#TRIGGER {Affects hp by &{Item.HPBonus}.} {} "eqdb"
#TRIGGER {Affects strength by &{Item.StrBonus}.} {} "eqdb"
#TRIGGER {Affects intelligence by &{Item.IntBonus}.} {} "eqdb"
#TRIGGER {Affects wisdom by &{Item.WisBonus}.} {} "eqdb"
#TRIGGER {Affects dexterity by &{Item.DexBonus}.} {} "eqdb"
#TRIGGER {Affects constitution by &{Item.ConBonus}.} {} "eqdb"
#TRIGGER {Affects damage roll by &{Item.Dam}.} {}"eqdb"
#TRIGGER {Weapon type is &{Item.WeaponType}.} {} "eqdb"
#TRIGGER {Damage is &{Item.Damage} ~(average %d~).} {} "eqdb"
#TRIGGER {$} {#IF (%numitems( %query( ((&Item.Name = @ItemName) & (&Item.Keywords = @ItemKeywords) & (&Item.Level = @ItemLevel)), All)) = 0) {#NEW @ItemType @Item} {gt already in there};#VARIABLE item {};#T- eqdb} "eqdb"


Please tell me it's something simple.

Dorrin
Reply with quote
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Sun Mar 09, 2003 10:38 am   
 
I use the %find() function to check for a repeated entry. This probably won't work for you since you want to check 3 fields.

That said, your problem is likely this:
quote:

%query( ((&Item.Name = @ItemName) & (&Item.Keywords = @ItemKeywords) & (&Item.Level = @ItemLevel)), All)



the DB variable "Item.Name" and string variable "ItemName" you declare with the same value in the first trigger. To get the value of a key of %rec use: &Name or &Keywords or &Level. You can take out the variables ItemName, ItemKeywords, and ItemLevel, since this information is duplicated in your DB variable. So the new call to query would look like:

%query( (&Name = @Item.Name) & (&Keywords = @Item.Keywords) & (&Level = @Item.Level), All)

--------

moon.icebound.net:9000
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