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
winnubst
Newbie


Joined: 01 May 2002
Posts: 0
Location: Namibia

PostPosted: Thu Mar 28, 2002 3:15 am   

Identify Script & Duplicates
 
I'm trying to follow the identify script in the help file:

#ALIAS identify {#T+ identify;#VAR Item "";cast identify %1}

#TRIGGER {Name: &Item.Name Type: &ItemType} {} identify
#TRIGGER {Cost: &Item.Cost} {} identify
#TRIGGER {Weight: &Item.Weight} {} identify
#TRIGGER {Damage: &Item.Damage} {} identify
#TRIGGER {Hit: &Item.Hit} {} identify
#TRIGGER {Dam: &Item.Dam} {} identify
#TRIGGER {$} {#T- identify;#IF (!%null(@Item)) {#NEW All @Item}} identify


I got it to work fine, except for that it does duplicate records. How can I find if a record is already in the database (eq) and then not write if it is or even better update the record.

Thanks in advance.
Reply with quote
kognesty
Newbie


Joined: 08 Jan 2001
Posts: 8
Location: USA

PostPosted: Thu Mar 28, 2002 7:09 am   
 
From my personal id database script this is part of an alias that is triggered on a blank line, as apposed to putting the whole mess in the $ trigger, I hope this will help you

#VAR dbCompare %query( ((&Object=@dbItem.Object)&(&Craftsmanship=@dbItem.Craftsmanship)&(&Armor=@dbItem.Armor)&(&Flags=@dbItem.Flags)&(&Affect=@dbItem.Affect)), dbType)
#VAR dbDoesExist 0
#IF (!%null( @dbCompare)) {dbDoesExist=1}
#IF (@dbDoesExist) {#YESNO "This record already exists in the current Database. Are you sure you want to add it?" {#NEW All @dbItem} {No:#NOOP}} {#NEW All @dbItem}


Basically what happens is the database is queryed to see if any entries have the same values, such as an item named the same with the same ac bonus or cost then a check is made to see if any database records where returned. If yes, you are prompted that the record already exists and asked if you wish to add a duplicate, if no the item is added to the database. This can easily be expanded to replace a database record if you wish, but I'll leave that part up to you.
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