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
JWhitney
Wanderer


Joined: 20 Oct 2006
Posts: 51

PostPosted: Wed Jan 05, 2011 4:07 am   

Returning a specific field in a database entry
 
I am looking for a way to return only a specific field for a database entry. I have a database of all of the mobs for my MUD, and I want to be able to search for a mob name and have it return only a specific requested cell, like this:

Database entry:
799 Security guard of Blain 220211 Hor Yes No

First number is the record, second is the XP value of the mob, the Hor, Yes and No aren't relevant. What I would like to do is something like this:

#FIND {security guard} XP

return:

220211

Is this achievable with CMUD's database?

Thank you for your time.
Reply with quote
shalimar
GURU


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

PostPosted: Wed Jan 05, 2011 10:49 am   
 
assuming the full name is used as the key....

$key=Security guard of Blain
$keyXP=@{databaseName.$key.xp}
#SAY $keyXP
_________________
Discord: Shalimarwildcat
Reply with quote
JWhitney
Wanderer


Joined: 20 Oct 2006
Posts: 51

PostPosted: Sat Jan 08, 2011 6:02 am   
 
Thank you very much for your reply. I gave it a shot as it was, and didn't find success yet. I'm probably doing something wrong. Here's what I did:

Made an alias (mobsearch), defined as:

$key=%1
$keyXP=@{MobList.$key.xp}
#SAY $keyXP

then "mobsearch Security guard of Blain"

just returns ".Security guard of Blain.xp"

Tried multiple variations, with brackets and without. I am unfamiliar with the $ operator in CMUD, maybe its purpose eluding me is causing my lack of understanding.
Reply with quote
shalimar
GURU


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

PostPosted: Sat Jan 08, 2011 3:12 pm   
 
the $ is the local variable operator
the problem in this scenario i think is because you are using an actual database instead of a DBvar, and I am not so good with those.
_________________
Discord: Shalimarwildcat
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Jan 08, 2011 4:54 pm   
 
Quote:

Is this achievable with CMUD's database [#FIND {security guard} XP ]?


Strictly speaking, I don't think #FIND lets you limit the search to a specific field. That said, you can refer to a specific field in a specific record using @, the number of the record, the first 2 letters of the database name, and the .key syntax: @148ar.repop (148 is the record I am looking at in my Areas database, and repop is the field that stores the area's repop message.)

You can also play around with %db() and %dbget().
_________________
EDIT: I didn't like my old signature
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Sat Jan 08, 2011 9:24 pm   
 
This really isn't all that hard to do. If each mob in your db has a unique name, and you will be searching with a string that will limit the result to only one record. Below is a picture of a sample db I created and an alias that when used with the unique name will return the exp value only. Given the format you listed in the first post it looks as if you have the name as the first field so that's how I set the alias up. The alias uses a temp trigger to return the value of the exp field, so if there is a chance that more than one record will be returned you will need to do a bit of modification, but this should be a good starting point.



Alias:
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="exp" copy="yes">
    <value>#temp {%d%s(*)%s(%d)%s} {#gag;#show %2;#dbr}
#find %-1</value>
  </alias>
</cmud>
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
JWhitney
Wanderer


Joined: 20 Oct 2006
Posts: 51

PostPosted: Mon Jan 10, 2011 12:17 am   
 
This actually worked perfectly! Thank you very much for your time!

My end goal in using the database is to be able to keep a record of the number of times I have killed each mob, and the average exp they've given for those kills, since the mobs in my MUD give a different amount of exp each kill. Occasionally, the mobs can be 'turbo', which makes them worth a much larger amount and much harder to kill - I want CMUD to be able to recognize a turbo version of a mob and flag it as such. Is there any reason this won't be doable with the CMUD DB?
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