 |
Death Apprentice
Joined: 25 Jun 2002 Posts: 109 Location: USA
|
Posted: Thu Jul 25, 2002 2:39 pm
Newbie to Databases in zMUD |
I have read some things on the database feature and can't seem to figure it out. I want to keep a database on mobs stat that I receive when I consider them. I'll give some examples of what the consider looks like on the mud I play on.
This is for a mob called Lord Kaldenbor, it doesn't display the name in the consider, but I was trying to get it attached with it so it would enter the database with it, so I know what mob it is.
Death will thank you for your gift.
Str: 28(25) Int: 24(24) Wis: 25(25) Dex:25(25) Con: 25(25)
Hp: 50025/50025 Mana: 1527/1527 Level: 250 Align -900
Immune: fire
Resist: fire
This is the Statue of the God Valor.
Your great grandmother could kill it.
Str: 30(25) Int: 24(24) Wis: 25(25) Dex:25(25) Con: 25(25)
Hp: 12733/12733 Mana: 500/500 Level: 105 Align 1000
Immune: summon charm magic poison disease
Resist: piercing slashing fire cold
Vulnerable: blunt lightning mental
If any of this is not possible, let me know. If you have any ideas or hints to get me started, that would be very helpful.
Thanks,
Death |
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Jul 25, 2002 3:22 pm |
Since this information will probably only come up when you consider, just make an alias for the consider command. In the alias, you can clear the database-variable and then assign its first key-value (the name of the mob), your triggers can then add additional key-values.
#AL con {#VAR mob %null;#ADDKEY mob name {%-1};consider %-1}
LightBulb
Senior Member |
|
|
|
 |
Death Apprentice
Joined: 25 Jun 2002 Posts: 109 Location: USA
|
Posted: Thu Jul 25, 2002 3:32 pm |
Ok, that works and captures the name of the mob. Then I need triggers to capture the rest of the data...would the following triggers work?
#TRIGGER {Str: (*) Int: (*) Wis: (*) Dex:(*) Con: (*)} {} @mob
#TRIGGER {Hp: (*) Mana: (*) Level: (*) Align (*)} {} @mob
#TRIGGER {Immune: (*)} {} @mob
#TRIGGER {Resist: (*)} {} @mob
#TRIGGER {Vulnerable: (*)} {} @mob
Ok, i've played with it myself and figured those wouldn't work...so I came up with the following...
#TRIGGER {Str: (*) Int: (*) Wis: (*) Dex:(*) Con: (*)} {#ADDKEY mob Str %1;#ADDKEY mob Int %2;#ADDKEY mob Wis %3;#ADDKEY mob Dex %4;#ADDKEY mob Con %5}
#TRIGGER {Hp: (*) Mana: (*) Level: (*) Align (*)} {#ADDKEY mob Hp %1;#ADDKEY mob Mana %2;#ADDKEY mob Level %3;#ADDKEY mob Align %4}
#TRIGGER {Immune: (*)} {#ADDKEY mob Immune {%1}}
#TRIGGER {Resist: (*)} {#ADDKEY mob Resist {%1}}
#TRIGGER {Vulnerable: (*)} {#ADDKEY mob Vulnerable {%1}}
Now my only problem is adding in more than 1 immune, resist, or vulnerable item if there's more than 1...The red stuff is the things i added to get them to work.
Scratch that. I've got it to store all immunes, resists, and vulernables. Is there a quick and easy way to create the DB and enter this info?
Thanks
Death |
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Jul 25, 2002 7:44 pm |
The only way to make a new database is through the DB window. Either start from scratch and add all your fields new or start from a template or copy of an existing db and edit the fields to what you want. If you start from a copy, you'll also need to delete any existing records.
Once you have your database set up with the fields/field types you want, enter one record manually. After that, you can use your alias and triggers to put the information in a database variable and use the #NEW command to actually input it to the database. You can use a trigger for this if you are able to identify a phrase which will positively mark the end of the data. Another possibility would be input the data from the last consider before you clear the variable in the alias.
LightBulb
Senior Member |
|
|
|
 |
Death Apprentice
Joined: 25 Jun 2002 Posts: 109 Location: USA
|
Posted: Thu Jul 25, 2002 8:48 pm |
Cool, i've created the database and it is storing everything. Is there a command to display the data of one of the fields?
Maybe..
#showdb kaldenbor
would bring up the stats kaldenbor from the database?
Hrmm, I've figured out that #showdb Kaldenbor won't work, but I did figure out #showdb <number_here>mo does...Is there anyway to assign the name instead of the number so i can just do the name for the stats instead of looking for the number?
Thanks,
Death
ps. Thanks for the help you've given my Lightbulb. That first reply got me going and learning most of the rest of the way. |
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Jul 26, 2002 4:30 pm |
You'll probably have to loop through the database to find the record you want.
#LOOPDB {#IF (%db(%rec,name)="kaldenbor") {#SHOWDB}}
If you put this in an alias, you can use %1 or a variable instead of "kaldenbor".
LightBulb
Senior Member |
|
|
|
 |
Death Apprentice
Joined: 25 Jun 2002 Posts: 109 Location: USA
|
Posted: Fri Jul 26, 2002 4:40 pm |
I played with it, and couldn't get the alias to work..
#AL find (*) {#LOOPDB {#IF (%db(%rec,name)="%1") {#SHOWDB}}}
Am I doing something wrong there?
Thanks,
Death |
|
|
|
 |
Kjata GURU

Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Fri Jul 26, 2002 9:43 pm |
The problem is that #LOOPDB doesn't actually loop through all of the records in the database, it loops through the keys in a specific record. To use LightBulb's suggestion, you would need #LOOPVIEW.
However, you can also do this:
#ALIAS {#FORALL %find("%-1") {#SHOWDB %i}}
This assumes that "name" is the first column in the database.
Kjata |
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Jul 26, 2002 11:02 pm |
Heh, thanks Kjata. I'm always on shaky ground when answering questions about maps or databases since I don't use them myself.
LightBulb
Senior Member |
|
|
|
 |
Death Apprentice
Joined: 25 Jun 2002 Posts: 109 Location: USA
|
Posted: Mon Jul 29, 2002 1:29 pm |
Ok, sorry I didn't get to check over the weekend. But when I type
#ALIAS {#FORALL %find("%-1") {#SHOWDB %i}}
I get...
Alias #FORALL {#SHOWDB %{i}} not defined
But if I add in a find (*) like so
#ALIAS find (*) {#FORALL %find("%-1") {#SHOWDB %i}}
If I type find Kaldenbor all i get is a * Kaldenbor
Maybe i'm reading it wrong, i've never been good with aliases.
Thanks,
Death |
|
|
|
 |
Troubadour GURU
Joined: 14 Oct 2000 Posts: 556 Location: USA
|
Posted: Mon Jul 29, 2002 3:49 pm |
Don't place the (*) after the name of the alias.
#ALIAS find {#FORALL %find("%-1") {#SHOWDB %i}}
Troubadour  |
|
|
|
 |
Death Apprentice
Joined: 25 Jun 2002 Posts: 109 Location: USA
|
Posted: Mon Jul 29, 2002 6:19 pm |
Sweet, it all works. Thank You everyone who assisted me in accomplishing this.
Death |
|
|
|
 |
|
|
|