Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Mon Jan 25, 2010 2:10 pm   

Database Newbie
 
I have the hang of database variables but less so to the fully functioal databases.
If i could get a crash course that would be great.

I am wanting to create an item list that would store details about each item i find such as: wear it is worn, weight, zone(s) found in, NPC's found on, item type (with the possibility of fields dependent on the type), where worn, item limit, weight capacity, damage type, protection level(s) offered.

What is the best field type for storing stringlists in a database? Command for adding items to said field?

What is the best way to link databases together? Should i bother with this level of complexity, or should i just have one list? I expect i will end up with hundreds if not thousands of items.

I expect I will not have information for all fields at once, perhaps not even all the fields. What is the best way to create new entries and/or add field data to preexisting entries instead of accidentally making duplicate entries?

That should be enough to get me started. Thank you in advance.
_________________
Discord: Shalimarwildcat
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Jan 25, 2010 2:54 pm   
 
I do not have the time to explain this at the moment, perhaps later though.

There are at least two tools in the library for this.

First there is Vijilante's toolbox. He has a tool in there that puts string lists within database records.
Like almost all of us his comments/help-file leave something to be desired, but there have been posts were we discussed how it works in the beta forum.

Second, I have a tool named Hashset in the library. Again a little difficult to understand how and why it works but I do have examples in its help.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Thu Jan 28, 2010 11:41 pm   
 
Okay... so i was playing around a bit, and this is the code i am using and it is working so far, though it does slow down the machine a bit at times. Maybe it could be optimized a bit?

Code:
#LOCAL $rec $loc $mob
$ItemList=%replace( %replace( %replace( %replace( %replace( %params, ", ", "|"), " (left hand)"), " (right hand)"), " (left hand and right hand)"), " and a", "|a")
#DBLOAD it
#FORALL $itemlist {#IF %match( %dblist( Name), %i) {
    $rec=%find( %i)
    #DBGET $rec
    $loc=&Location
    $mob=&Mobs
    #IF (%ismember( %zonename, $loc)) {#NOOP} {$loc=%sort( %concat( $loc, "|", %zonename))}
    #IF (%ismember( @lookedAt, $mob)) {#NOOP} {$mob=%sort( %concat( $mob, "|", @lookedAt))}
    #DBPUT $rec Location $loc Mobs $mob
    } {
    $rec=%eval( %numrec+1)it
    #DBPUT $rec Name %i Location %zonename Mobs @lookedAt
    }}
#DBSAVE
_________________
Discord: Shalimarwildcat
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Jan 29, 2010 2:11 am   
 
Well, here is a small tweak to start with.

Code:
#LOCAL $rec $loc $mob
$dif=0
$ItemList=%replace( %replace( %replace( %replace( %replace( %params, ", ", "|"), " (left hand)"), " (right hand)"), " (left hand and right hand)"), " and a", "|a")
#DBLOAD it
#FORALL $itemlist {#IF %match( %dblist( Name), %i) {
    $rec=%find( %i)
    #DBGET $rec
    $loc=&Location
    $mob=&Mobs
    #IF (%ismember( %zonename, $loc)==0) {$dif=1;$loc=%sort( %concat( $loc, "|", %zonename))}
    #IF (%ismember( @lookedAt, $mob)==0) {$dif=1;$mob=%sort( %concat( $mob, "|", @lookedAt))}
    #IF ($dif==1) {#DBPUT $rec Location $loc Mobs $mob}
    } {
    $rec=%eval( %numrec+1)it
    #DBPUT $rec Name %i Location %zonename Mobs @lookedAt
    }}
#DBSAVE


Please let me know if it does any better, or even works. Laughing
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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