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
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Tue Nov 26, 2002 3:27 am   

Data Record Variables
 
Is there a way to search a specific data record variable for a specific name and number, and then be able to extract the it? I use data record variables to track how many times each person in my party does a critical hit. Here is the basis:

#TRIGGER {^(%w)'s attack breaks bones!$} {#add pcrit_bone.%1 1}

The variable makes a list like:

Tony: 1
Frank: 3
Dan: 2

There are many different types of critical messages, so I have something like 20 or 30 different records, each containing the names of party members and their critical counter. I would like to be able to make an alias to check each record for a specific name, and extract that name and his/her counter, to display in a list for that person specifically.

Ex-
Instead of 20 or 30 different records like
Tony: 1
Frank: 3
Dan: 2

I would like to make an alias to do this:

Name: Tony
Bone Breaker: 2
Spasm: 3
Bloody Mess: 1
Zap: 9

Any ideas on how I could do this?

Fat Tony
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Nov 26, 2002 4:54 am   
 
Yep, there's a function called %iskey() that can help you as far as finding a particular field in a data record. If you find it, then all you need to do is reference that field.

#TRIGGER {^(%w)'s attack breaks bones!$} {#if (%iskey(%1,pcrit_bone) {#addkey pcrit_bone %1 %eval(%db(pcrit_bone,%1) + 1)} {#noop it's not part of the variable}}

li'l shmoe of Dragon's Gate MUD
Reply with quote
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Tue Nov 26, 2002 6:18 am   
 
Okay, that does give me a true/false for a specific record, but I'm trying to place this in an alias to essentially create a NEW record of ONLY that person's criticals and the number of each.

Ex-
#ALIAS {pcrit} {
#if (%iskey( @pcrit_bone, %1)) {#addkey {pcrit.%1} {Bone Breaker} {2}} {#noop}
#if (%iskey( @pcrit_spasm, %1)) {#addkey {pcrit.%1} {Spasm} {3}} {#noop}
#if (%iskey( @pcrit_bloodymess, %1)) {#addkey {pcrit.%1} {Bloody Mess} {1}} {#noop}
#if (%iskey( @pcrit_zap, %1)) {#addkey {pcrit.%1} {Zap} {9}} {#noop}
#say %1's Party Criticals
#showdb @pcrit.%1
}

Would ideally display:
Tony's Party Criticals
Bone Breaker 2
Spasm 3
Bloody Mess 1
Zap 9


Got the basic part down, but I still need to be able to extract the actual NUMBER of each counter, if its possible.

Anything I can try?


Fat Tony
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Nov 27, 2002 2:08 am   
 
Did you look at the trigger I posted? The answer (a single function) is given therein.

li'l shmoe of Dragon's Gate MUD
Reply with quote
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Wed Nov 27, 2002 8:59 pm   
 
Wow, I missed that completely in the trigger. I apologize for my ignorance, and thank you for your help. I set up the alias and it work perfectly, thank you very much.

Fat Tony
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