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


Joined: 21 May 2002
Posts: 0
Location: USA

PostPosted: Wed Apr 24, 2002 3:56 am   

Find and Replace in Database
 
I'm having some trouble with an EQ database i'm creating. It captures every tidbit of information perfectly, and adds it to the database, but my problem lies in the fact that if an earlier version already exists, the script simply adds another copy without searching if it already exists.

so, i tried putting a script together that would search the database and update any stats if it finds it.

Example:

A steel sword has a HR of +3 and DR of +4

it's already in the database as +2 and +3 respectively. My script would go through the database, find the item named "a steel sword" and change it's HR/DR values from 2/3 to 3/4.

Here is the find/replace portion of the script:

note: @Item is the array with the information from the item that was just identified (ie the new item).

@ItemLocation = %find(%db(@Item,Object))
#if (%null(@ItemLocation))
{
#NOOP Item doesn't exist, so add it.
#NEW All @Item
}
{
#VARIABLE OldRecord @ItemLocation
#if (@OldRecord.Value < &Item.Value, @OldRecord.Value = &Item.Value)
#if (@OldRecord.AC-apply < &Item.AC-apply,@OldRecord.AC-apply = &Item.AC-apply)
#if (@OldRecord.Mana < &Item.Mana,@OldRecord.Mana = &Item.Mana)
#if (@OldRecord.AGE < &Item.AGE,@OldRecord.AGE = &Item.AGE)
#if (@OldRecord.STR < &Item.STR,@OldRecord.STR = &Item.STR)
#if (@OldRecord.DEX < &Item.DEX,@OldRecord.DEX = &Item.DEX)
#if (@OldRecord.CON < &Item.CON,@OldRecord.CON = &Item.CON)
#if (@OldRecord.WIS < &Item.WIS,@OldRecord.WIS = &Item.WIS)
#if (@OldRecord.INT < &Item.INT,@OldRecord.INT = &Item.INT)
#if (@OldRecord.STA < &Item.STA,@OldRecord.STA = &Item.STA)
#if (@OldRecord.DR < &Item.DR,@OldRecord.DR = &Item.DR)
#if (@OldRecord.MOVE < &Item.MOVE,@OldRecord.MOVE = &Item.MOVE)
#if (@OldRecord.HP < &Item.HP,@OldRecord.HP = &Item.HP)
#if (@OldRecord.HR < &Item.HR,@OldRecord.HR = &Item.HR)
#if (@OldRecord.AC > &Item.AC,@OldRecord.AC = &Item.AC)
#if (@OldRecord.SavingSpell > &Item.SavingSpell,@OldRecord.SavingSpell = &Item.SavingSpell)
#DBDEL @ItemLocation
#NEW All @Item
}

any help appreciated...
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Apr 26, 2002 4:28 pm   
 
I think the problem is that your variable, @OldRecord, is not a database variable. It comes from the line:
#VARIABLE OldRecord @ItemLocation
so it will be something like 20eq. That is, it will be the record number instead of the record.

What you probably need is something like
#VARIABLE OldRecord %dbget(@ItemLocation)

LightBulb
Vague questions get vague answers
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