 |
Nangasaur Newbie
Joined: 02 Jan 2007 Posts: 8
|
Posted: Tue Jan 02, 2007 7:24 am
LOOPDB, FORALL - a little stumped at the moment :) |
I've searched around here and unfortunately am not finding what I think I'm looking for.
Basically what I've done is taken an idea along the lines of something "Private" posted here, where he wants to someday write a script that can automatically update/correct DB entries for mob names, area names, and room names. I'm starting completely from scratch and my coding experience is very primitive in comparison to others I read here, so bare with me.
So far I've written a very effective script that takes the output of "mobdeaths 1 1 evil", and dumps the proper data I'm looking for into a nice and neat DB, all sorted properly, etc.
Which leads me to my current problem. Some of the mob names and area names are cut short at the end by the MUD's output. So, I want to create an alias that sorts through my entire DB and corrects things like the shortened area names by changing the value to the correct, full name of the area.
Here is my code thus far:
#FORALL @AreaNames {#IF (%db(test,Area)=%i) {#ADDKEY %rec Area "Blah Blah Blah"} {}}
Where @AreaNames is a standard variable list in my script that contains all the incorrect area names. "Blah Blah Blah" is what I want it to change the DB key value to if it encounters @AreaNames in the DB.
The above code works "somewhat", in that it changes the current DB record to "Blah Blah Blah", regardless of if it matches @AreaNames or not. *sigh* I don't want it to do that.
My second problem with it, once I get the first corrected, is how to use LOOPDB to go through my entire database, record by record, and change each key value that matches @AreaNames to "Blah Blah Blah".
Any help is appreciated, thanks. |
|
|
|
 |
Nangasaur Newbie
Joined: 02 Jan 2007 Posts: 8
|
Posted: Wed Jan 03, 2007 4:58 am |
Ok well, I've discovered another way of doing this...to basically have it make the corrections on it's own while it's adding entries into the database. Any advice on making my syntax a bit more efficient? I'm not happy with how it looks, even though it is working properly the way I want it to.
| Code: |
| #TRIGGER {^%s%d - (*)%s (%d)%s(*)%s (%d)} {#VAR MobName1 {%1};#VAR MobLevel {%2};#VAR AreaName1 {%3};#VAR MobDeaths {%4};#PRIO {#LOOPDB @AreaNames {#IF (@AreaName1=%key) {#VAR AreaName1 %val} {}}};#NEW test {Name=@MobName1|Level=@MobLevel|Area=@AreaName1|Deaths=@MobDeaths}} mobdeathslogging |
|
|
|
|
 |
Nangasaur Newbie
Joined: 02 Jan 2007 Posts: 8
|
Posted: Thu Jan 04, 2007 2:40 am |
OK this is where I'm at so far (still looking for a little guidance here, folks).
I issue the command "mobdeaths 1 1 evil" to display all the mobs of level 1, evil alignment, their area name, and how many times they've been killed.
The output from the MUD looks like this:
| Quote: |
1 - A fire newt worker 1 The Land of the Fire 119
2 - A field mouse 1 Gallows Hill 90
3 - A small bug 1 Tournament Camps 90
4 - A black cat 1 Gallows Hill 78
5 - A spider 1 Gallows Hill 76
6 - An old goblin 1 The Goblin Path 66
7 - A deer tick 1 Gallows Hill 65
|
...well, there's a bunch of extra spaces in there and such, but for what I'm showing here it's irrelevant.
My trigger
| Code: |
| #TRIGGER {^%s%d - (*)%s (%d)%s(*)%s (%d)} {#VAR MobName1 {%1};#VAR MobLevel {%2};#VAR AreaName1 {%3};#VAR MobDeaths {%4};#PRIO {#LOOPDB @AreaNames {#IF (@AreaName1=%key) {#VAR AreaName1 %val} {}}};#NEW test {Name=@MobName1|Level=@MobLevel|Area=@AreaName1|Deaths=@MobDeaths}} mobdeathslogging |
This collects the mob name, mob level, area name, and death count, then sends it to my database perfectly.
What I'm wanting to do next is extract the name of a mob (take the first example: "a fire newt worker") from the currentview db record. However, I only want it to extract the last word of the mob's name (in this example: "worker"), and send it to the command line as a variable.
Basically so I can go to the area that "a fire newt worker" resides in (the land of the fire newts), and execute an alias that sends the command:
where worker
Then extract the output of this command, and send part of that output to the 5th field of the current db record (room name). I know how to do this part, it's the part above that I'm trying to figure out (extracting partial keyval data and using it in another alias).
Is this at all possible? |
|
|
|
 |
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Thu Jan 04, 2007 2:40 am |
One possible problem I see is that keys in db variables don't work well with spaces. This is not a problem if your area names never have spaces, but I'm guessing that they do.. also it doesn't seem to be a problem with the way you're doing it, but using, for example, @{AreaNames.@AreaName1} which wouldn't require looping, -would- have problems with spaces.
Edit: How about a combination of %match() and %right() on your variable storing the name of the mob? |
|
|
|
 |
Nangasaur Newbie
Joined: 02 Jan 2007 Posts: 8
|
Posted: Thu Jan 04, 2007 2:48 am |
| gamma_ray wrote: |
| One possible problem I see is that keys in db variables don't work well with spaces. This is not a problem if your area names never have spaces, but I'm guessing that they do.. also it doesn't seem to be a problem with the way you're doing it, but using, for example, @{AreaNames.@AreaName1} which wouldn't require looping, -would- have problems with spaces. |
Oh yeah definitely :) I was having huge problems with the spaces, but the trigger itself is rigged so that it's grabbing the entire data for each field and dumping into the db exactly how I want it. I was a little amazed at first when I finally got it (even now I'm not fully understanding why it's doing it properly, but it is).
The reason why I have AreaNames looping is because it's a var within the script that has data like this:
| Quote: |
Key: The Wobbly Woes of W Val: The Wobbly Woes of Woobleville
Key: The Darkside of Domi Val: The Darkside of Dominia |
This is necessary because the output from the mud cuts off the end of names that are too long, but I want my database itself to have the full length name. So when the trigger hits on the partial area name, and it's in the AreaNames var, instead of the partial name being sent to the Area field of my DB, the full length name is sent. |
|
|
|
 |
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Thu Jan 04, 2007 4:03 am |
Yeah, I did something like that for an item parser once, however I was using the @{var.key} way of accessing it which was breaking with spaces. The looping looks like a nice work-around, if I ever try writing that script again I'll probably try it that way. Did you try %match yet to get the last word for your mobs?
|
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Thu Jan 04, 2007 10:46 pm |
Multi-word datarecord keys work perfectly fine in ZMud. Just not with the @var.key syntax, you have to use %db() any time you want to access that key.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
chris-74269 Magician
Joined: 23 Nov 2004 Posts: 364
|
Posted: Fri Jan 05, 2007 1:53 am |
use %lower(%item(list var,%numwords(listvar))) to get the last word of the mob you want, so a fire newt would go to newt, ect.
|
|
|
|
 |
|
|
|
|
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
|
|