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
xenothought
Beginner


Joined: 16 Sep 2002
Posts: 11
Location: USA

PostPosted: Thu Sep 19, 2002 4:01 pm   

Stopping Dupes
 
Does anyone know how to make a database log stop from creating dupe items?

hello there.
Reply with quote
horks
Apprentice


Joined: 20 Jul 2001
Posts: 127
Location: USA

PostPosted: Thu Sep 19, 2002 6:52 pm   
 
just put a #if command in it ...

something like this:

#VARIABLE dbcheck {%numitems( %find(search_name))}
#IF !(@dbcheck) {#NEW blah blah}

Father Horks
The only problem with computer security, is when you think it exists.
Reply with quote
xenothought
Beginner


Joined: 16 Sep 2002
Posts: 11
Location: USA

PostPosted: Fri Sep 20, 2002 7:39 pm   
 
I dont understand how that var works...explain it more?

hello there.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Fri Sep 20, 2002 8:15 pm   
 
The %find function searches the first field of each record in the database to see if it matches whatever argument you pass to it (this function may also search some other field, but that is not the syntax shown here.) A list of all matching record numbers is returned. Suppose you have a database of potions and the first field of each record is the Name. Then, doing:
%find("red")

will look for all records that contain the string "red" in the first field. It might return something like this:
1po|3po|5po|13po

The two letters after the number are the short name of the database. In this case, I'm using "po" as an example.

%numitems returns the number of items in a stringlist. Thus, doing:
%numitems(%find("string"))

will return the amount of records in the database that have string somewhere in the first field. This value is saved to @dbcheck.

Next, before adding the new item to the database by using the #NEW command, we check to see if @dbcheck is false. If it is false, we add the new record to the database. the way this works is because zMUD interprets any non-zero value as true and zero values as false. If no items match your search string in %find, the length of the stringlist returned will be zero and @dbcheck will be false. If one or more items match, the length of the stringlist will be a non-zero value and @dbcheck is interpreted as true.

Kjata
Reply with quote
xenothought
Beginner


Joined: 16 Sep 2002
Posts: 11
Location: USA

PostPosted: Mon Sep 23, 2002 4:29 pm   
 
ok I understand how that works...but I dont think its working in the latest beta which I'm on so I guess the reason its not correct is my fault...You brought up a good point to me tho...is there a way to use the item type trigger to set a different Dbase to log the item too? so I can log it to potion, or Weapon automaticly?

hello there.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Sep 24, 2002 1:19 am   
 
The best solution, instead of having multiple databases, is to have just one database that contains everything, but has multiple views. In this scenario, you would have a database with fields like dam, hit, level, name, description, value, spell1, spell2, spell3, ac, damage, etc. However, not all items use all of these fields (for example a potion would probably only use name, level, description, value, spell1, spell, spell3.) So, you create different views (one for weapons, another for armor, etc.) that shows only the fields that apply to that type of item. When adding the item to the database, you specify the correct view based on the item type returned by the identify. The database would also have, by default, a view called All which would show all of your different items and all of the different fields even if a particular record does not use a particular field. More information may be found in the Introduction to the Database section of the help file.

Kjata
Reply with quote
xenothought
Beginner


Joined: 16 Sep 2002
Posts: 11
Location: USA

PostPosted: Tue Sep 24, 2002 6:08 pm   
 
Ok everythign is working wonderfully with the views and the database and the dupes...now my problem is...How can I set the Database to log the item under the right numname thing? right now my Dbase is named Astro...everything logs under NUMastro...how would I get the weapons to log under NUMweapon etc. any ideas?

hello there.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Sep 24, 2002 10:02 pm   
 
I'm sorry, I don't follow you. You want to change the name of your database?

Kjata
Reply with quote
xenothought
Beginner


Joined: 16 Sep 2002
Posts: 11
Location: USA

PostPosted: Tue Sep 24, 2002 11:25 pm   
 
no just how it loggs an item int he Dbase...or will it always log it as NUMname
instead of NUMweapon, NUMpotion, NUMitem etc.?

hello there.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Sep 25, 2002 5:09 am   
 
If it's record 17 in the Astro database, it will always be 17as, no matter which view is being used. This would only change if you actually switched to another database.

Some people have one database for equipment, and another for monsters. So they could have 17eq and 17mo. But it has to be different databases, not just different views. If they had different views for armor and weapons, but they were both in the equipment database, it would still be 17eq -- NOT 17ar or 17we.

Hope that helped make things clearer instead of more confusing.

LightBulb
Senior Member
Reply with quote
xenothought
Beginner


Joined: 16 Sep 2002
Posts: 11
Location: USA

PostPosted: Wed Sep 25, 2002 2:45 pm   
 
no I understood that I was just hoping there was a way to autolog types into different databases :D no biggie tho everythign works great now...thank you all for your help.

hello there.
Reply with quote
xenothought
Beginner


Joined: 16 Sep 2002
Posts: 11
Location: USA

PostPosted: Wed Sep 25, 2002 2:45 pm   
 
no I understood that I was just hoping there was a way to autolog types into different databases :D no biggie tho everythign works great now...thank you all for your help.

hello there.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Sep 25, 2002 6:57 pm   
 
Well, you could.
First, create separate databases for each type.
Then, use the trigger that catches the type to close the current database and open the matching database.

However, a database covering all types of equipment is generally much more useful than individual databases. It's also easier to use.

LightBulb
Senior Member
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