Variable Variables...

by Daganev

Back to Mechanic's Corner.

Daganev2005-04-27 23:53:50
Ok, so I have access to powerlogs now, and boy are they spammy!

I've made the following trigger in Zmud
CODE

#trigger {%d/%d/%d %d:%d - (%w) used -(%2) power at the Master Ravenwood Tree} {

#CLASS Powerlog
#GAG
#ADD %1_Used_Power %2
#CLASS 0
}


This creates a whole bunch of variables in my powerlog class that look like the following...

Daganev_Used_Power
Elaria_Used_Power
Gwynevere_Used_Power


I want to make a Trigger on the last like of the powerlog that looks like this..

CODE

#trigger {%d/%d/%d/ 00:00 - *} {
#class powerlog
#IF (%1_Used_Power > 20) {#Show %1 Overdrew} {%1_Used_Power = o}
#CLASS 0


Now obviously, %1 only works on that trigger, and such code will only run once for one person... but I want it to check all the Variables that are basically (%w)_Used_Power and see if they took too much.

Thanks! Hope its possible.
Murphy2005-04-28 00:00:19
probably better off entering a stringlist

so that it goes something like this.

#trigger {%d/%d/%d %d:%d - (%w) used -(%2) power at the Master Ravenwood Tree} {

#CLASS Powerlog
#GAG
#ADD %1_Used_Power %2
#IF (@%1_used_power > 20) {#add overdraw_list %1{
#CLASS 0
}

then do show overdraw_list
Unknown2005-04-28 00:03:32
I don't use zmud, so you'll have to figure out the syntax for this.

I know I've seen people talking about string-lists and arrays in other zmud posts. As your variables are created, you could add that person's name (if it doesn't exist already) to the string-list/array. Then have a loop go through that list of names to check the associated variables. As variables are deleted, remove their name from the string-list/array.

(Edit: Well crap, looks like Murphy beat me to it...and he had your syntax happy.gif )
Daganev2005-04-28 00:05:49
Ahh, a condition in the intial trigger... why didn't I think of that? sweet, thanks.

I still wish you could use pattern matching on variable names.. that would be so usefull.
Daganev2005-04-28 00:12:42
Ok, now for the next question...

How do I 'freeze' the numbers of what they OFFERED instead of used, so if I do powerlog twice in the same month it doesn't double up on them.


Wait... Murphy's sollution still doesn't work if I look at the powerlog twice in the month.. which is why I needed this list....
Summer2005-04-28 07:59:19
One possible solution if zMud can do it:

Create a group / class called "power".

Alias RLPM (or whatever) to delete the "power" group, recreate the group, and then read the powerlog.

Any variables created by the powerlog gets saved under "power" group, so it gets reset everytime you read the log.

Is probably useful for not having an extra big variable list especially if you get names that pop in for a few days and then vanish never to be seen again.
Gwylifar2005-04-28 13:31:45
I do this in a database variable, myself: %key = name, %val = amount. I also maintain a stringlist of names at the same time, so I can sort it at the end, so I can present my summary report to myself in sorted order.

As Summer suggests, all the variables are in a folder which I reset at the start of capturing a log. Also, the triggers are in another folder which gets enabled then, disabled at the end, so it won't slow things down or do odd things when I read other logs and something happens to look too similar (should never happen, but best to be sure).

I also maintain another database variable of "exceptions" (so-and-so can draw this much power during this date range) which gets automatically purged when the dates pass (some exceptions are permanent). When I do blocks, I add those to another database variable so that when the date passes the unblock happens automatically.
Daganev2005-04-28 16:51:33
How do I reset all the variables if I don't know what the name of the variable is going to be? That is my question.
Summer2005-04-28 17:03:45
I dunno. My solution = deleting the group (to get rid of everything), then do an alias that will re-trigger the stuff needed to set the aliases in the re-created group. Unfortunately I don't use zMud, so I can't tell you the syntax, or if it is even possible for you.
Unknown2005-04-28 18:00:51
QUOTE(daganev @ Apr 28 2005, 11:51 AM)
How do I reset all the variables if I don't know what the name of the variable is going to be?  That is my question.
109019



If you want to reset the variables to some default value, store them in a separate class folder, but create them using the #VAR command with a default value field. Then you can use the #RESET command to set all variables in the folder to their defaults.
Daganev2005-04-29 23:12:48
Ahh, good ol' reset...

How do I use reset to make sure its only affecting the class I want it to?
Gwylifar2005-04-30 01:54:20
#reset "Your|Class|Path|Here"