Zeroing out entries in the session log via a script

Winterbay

Active member
I have a login script that when I log in makes sure I have 100k at hand (takes it from the closet). This leads to the "Meat Gained:" part of the session log to update with either plus or minus a lot (dependingon what I did last day and how well my store has sold during the night).

Is there any way I can either make the Session Result not update with my closet-tinkering or if not a way to zero out that log before doing anything else?

Said chracter normally automatically runs a farming script directly afterwards and it is difficult to know how much it has made or not during the day when the session result is affected by my login-action.
 
Wouldn't an easier solution be to have a daily property that held meat from the start of the day, which you set via ash, which you could compare to at the end of your farming?
 
Yes... Properties is a good way to go. I think I'll do that. Thanks.

Since Mafia automatically calculates the value of my store when I go there, is it possible to get to that information in anyway? Or do I need to go through every item in the game to see if ti is in my store and then assess its value? (the script dumps a lot of things into the mall automatically and I think potential earnings should be taken into account when assessing the day's farming)
 
Heh, was bored, so here's something you can use to create a store snapshot. You'll probably want to tweak it for your purposes, but hopefully this will save a bit of effort.
 

Attachments

Oh thanks a lot :)
I see you used RegEx... not something I've ever managed to grasp yet. It should perhaps be a project sometime...
 
There's some decent help on the wiki. Just keep in mind that most special symbols need to be double-escaped (once for mafia's string-handling and once to be a regex control character*). I've gotten to be fairly comfortable with regex in ash, so feel free to shoot me any questions.

* Edit to add: I'm aware this is a simplification. ;)
 
Last edited:
In the wiki's regex building page, one of the links there to help test your regex will let you build it normally and give you a Java version with the extra backslashes. Very handy when you're trying to figure out just how the heck it's supposed to look.

And since you mentioned stores, here's a couple regexes ready to go for mafia. I have have them saved as part of a library file, but they should be very helpful for you:
Code:
string regex_name="([\\w\\d\\s]+)"; //Group matching for a player's name
string regex_id="href=\\\"showplayer\\.php\\?who=(\\d+)\\\"";  //Group matching for a player's ID number
Maybe these should be added to the wiki as examples?
 
Don't names have to start with an alphanumeric character? And they can't end in a space? And they're limited to 30 characters? Ie:
Code:
string regex_name = "(\\w[\\w\\d\\s]{0,28}[\\w\\d]{0,1})";
Edit to add: Is the triple-escape needed for quotes? I've done ok with a single-escape.
Edit2: Hrm, that assumes escaping directly in create_matcher(); that may be necessary when saving a string variable. Also, there are a few places where the ID doesn't become a link, so I prefer using:
Code:
string regex_id = "\\(#(\\d+?)\\)";
Also, I think using greedy matching is kinda dangerous, especially if the matcher variable is added on to additional info to build a larger matcher. ;)
 
Last edited:
I have yet to find a name that wasn't surrounded by > and < which are both non-word, non-digit, and non-space. If I'm wrong, point my to an example please! :)

As for the triple backslash for the quote, there was a very good reason, though I can't remember why...
 
Clan activity logs follow "<br>" or "<blockquote>" with a player name, then space, then ID in a plain (no html-tag) format. I made a monster of a log parser, so I had to deal with this. Still, when you have the possibility of extra text being checked, I stand by avoiding greedy matching (use those question marks!). :p As for the triple-backslash, I'm guessing my above guess may be the reason, in at least some circumstances.

Edit to add (gar, I need to pause before hitting that button):

I do strongly agree that a library of similar regex patterns of use in KoL would be good to put on the wiki, along with notes on restrictions / use-cases. Sounds like a fun project; thanks for volunteering! ;)
 
Am I correct in my interpretation if I say that the matcher "\\d{1,9}" matches everythign from 1 to 999999999?

Also: I have today incorporated that script into my login-script. The result tomorrow shall be interesting :)
 
Nope... 1,9 matches everything from 1-9, 11-19, 21-29, 31-39, 41-49, 51-59, 61-69, 71-79, 81-89, 91-99, 111-119, etc...

Note that it's missing the 0. For the matcher you desire, I THINK you want 0,9.
 
Hmm... My impression from the wiki regexp-entry was that {1,9} would match from 1 to 9 characters of whatever signifier was before it, in this case digits.
 
\\d{1,9} will actually match everything from 0 to 999999999. It'll also match stuff like "0000000", which may be an issue. :P

edit: Also, jumping onto the regex discussion bandwagon -- StD, I'm pretty sure that \\w includes all of \\d -- the former should be functionally equivalent to [a-zA-Z0-9_].
 
Last edited:
hee3: garfpuff, dargnabit. Yeah, that name regex should be
Code:
string regex_name = "([a-zA-Z][\\w\\d\\s]{0,28}[\\w\\d]{0,1})";

Once we get all of the bugs out we can move these over to the wiki. ;)

And yes, Winterbay is correct that \\d{1,9} matches any number from 0 to 999999999. But don't forget that a lot of KoL numbers are comma-formatted, so you should probably use:
Code:
string regex_number = "(\\d(?:,?\\d{3}){0,2})"
for most of them (shown to match as a group, remove outer parenthesis otherwise). Also, don't forget that there are some places in KoL (such as mall item quantities in your store) where a quantity of 1 is described by listing the item / etc. without any number whatsoever, so that's even more fun.
 
And yes, Winterbay is correct that \\d{1,9} matches any number from 0 to 999999999. But don't forget that a lot of KoL numbers are comma-formatted, so you should probably use:
Code:
string regex_number = "(\\d(?:,?\\d{3}){0,2})"
for most of them (shown to match as a group, remove outer parenthesis otherwise). Also, don't forget that there are some places in KoL (such as mall item quantities in your store) where a quantity of 1 is described by listing the item / etc. without any number whatsoever, so that's even more fun.

Thanks. I was mainly trying to work out what the different regexpes in your script did :)
They take some time wrapping your head around but I can see how they can be really useful for parsing of things.
 
Sorry... I did some reg_exp stuff with lua and mud clients, but in that case my string ended up being rather specific in terms of what type of characters were allowed... ([0-9]*) was my standard number match bit. Missed the difference between commas and hyphens. :D
 
Back
Top