ZLib -- Zarqon's useful function library

All that "set _version_zlib =" does is use zlib to change a var setting for your character in your character's vars txt file. You can just do that yourself by opening up your text file and deleting the setting yourself.
To be totally safe, you could just open your settings file(s) and delete everything that starts with "_version_".
 

zarqon

Well-known member
Ninja: wrong. Script version info is stored in mafia daily preferences, not ZLib vars. You will not find that setting in the vars text file, but you will find it in your mafia settings file.
 
Sorry. That's what I meant. That's why I quoted you Z, sometimes I type something different than what I'm thinking, but copy and paste generally keeps me safe. Sorry again.
 

Tipmon

Member
hey i have a problem i tryed to run another one of your scripts(eatdrink to be specific) and when i did it said
"undifined reference to function 'modifier_eval'(zlib.ash, line 67)"
any help?
and explain it easy im new here : )
 

zarqon

Well-known member
Welcome. You want to visit http://builds.kolmafia.us/ and get the most recent build of mafia. You can either replace your previous mafia with the daily, or else just save and run it in the same location. Most scripters are rapid adopters of new features, so if you want to run scripts it's advisable to always try a current build of mafia as your first recourse when encountering problems.

Also, EatDrink is by dj_d, a fine upstanding individual who is not me! :)
 
I have a question about the section of auto_mcd() that checks for MCD access. Do moxie signs really need the meat car to get to the Annoy-o-Tron, or just beach access?

I like to rip things out into separate functions, and hate long if conditions: here's what I'm using at the moment for roughly the same functionality as your if statment. Comments?

Code:
# Checks to see if you can get to an MCD and trys to get you one if you don't.
# Returns true if you now do, false otherwise.
# Heartbreaker's returns false, because it costs turns to set.
boolean has_mcd()
{
  # Myst signs have the One True MCD
  if (in_mysticality_sign()) return true;
	
  # Muscle signs should buy it if they need it
  if (in_muscle_sign()) return (retrieve_item(1, $item[detuned radio]));
	
  # Moxie signs need to be able to get to the beach
  if (in_moxie_sign()) return canadv($location[South of the Border], false)
	
  # If it's your first ascension or you're in Bad Moon, tough luck
  return false;
}

On the other hand, adopting such a method in zlib would require that zlib include canadv, which itself includes zlib. That seems like a Bad Thing. Mafia may deal well with multiple inclusions of the same file, but nothing can really deal with circular inclusions.

I'm still curious about the meatcar, though.
 

zarqon

Well-known member
This has been mentioned at least five times before, in both this thread and the BBB thread (it was formerly AutoMCD).

Write me a method of detecting beach access that doesn't hit the server and it's fixed. I haven't thought of one yet, although there's a halfway fix in the next update (accessing the CanAdv setting, if it exists).
 
Last edited:
Well, fair enough. Server hits are Bad, especially as auto_mcd() is often run in loops. (Please accept my apologies for bringing it up again; an in-thread search for "meatcar" didn't yield anything relevant, because I am a moron -- "meat car" would have been the correct search.)

Riffing on the "use the canadv property if it's there", could something like perm_urlcheck() be incorporated into zlib? I imagine ripping the property-loading code and the function itself out of canadv() and whacking it into zlib, with the loading code at top-level.

I don't have a good feel for how generally-useful perm_urlcheck() is, however. Maybe not enough to merit incorporation in zlib? But it's such a nice elegant way of replacing server hits...
 

zarqon

Well-known member
Even taking perm_urlcheck() from CanAdv wouldn't work -- because until you actually unlock the beach, it would keep hitting the server between combats.

Making a ZLib version of perm_urlcheck() is an interesting idea -- and would have plenty of server-hit-saving uses -- but I think the only way it could be made to work generally is if it used a separate property for each url (or the property name would be a function parameter). That could hypothetically add quite a lot of bloat to mafia's settings file, but in use it boils down to a) how many people would use it, and b) whether saving server hits is worth the bloat. Thoughts, anyone?
 
Oh right. I've been using my pageCache.visit_cached_url so that repeatedly checking the same page doesn't hit the server when I do it.

But... the point is that you do have to hit the server in this case. Right? Because you want to know if the page has changed to now meet your criterion (i.e. the beach now being open). Your cached stuff looks really neat, but still doesn't get around the problem here.
 

zarqon

Well-known member
I think this halfway solution will actually work pretty well. People who have untinkered their meatcars but still want to auto-MCD can simply run CanAdv once, specify South of the Border, and then all will be well.
 

Bale

Minion
While adding zlib to newLife, I noticed version 10's undocumented change to check_version(). That's ingenious really. Brilliant little bit of coding.
 
But... the point is that you do have to hit the server in this case. Right? Because you want to know if the page has changed to now meet your criterion (i.e. the beach now being open). Your cached stuff looks really neat, but still doesn't get around the problem here.

True. If you check for MCD availability, then construct the meatcar, complete the quest, and untinker the meatcar all on the same turn (which is a common scenario) you'll get the old cached page.

I really wish I had a way to hook council and guild visits. Too bad lastAdventure doesn't reflect it.

I think your "half solution" is a reasonable work around, but it feels inelegant. I'm sure we'll keep pecking at it till we figure something out.
 

zarqon

Well-known member
The council is pretty easy. I usually just include

PHP:
if (my_level() != get_property("lastCouncilVisit").to_int()) visit_url("council.php");

for quest-sensitive scripts. That works for almost all of them.

The guild, on the other hand, is definitely something that needs reworking in CanAdv (the present function is mostly a placeholder). Calling the CLI "guild" is just a stopgap and is sometimes undesirable. It needs to be smarter about knowing when to check in with the people in your guild (and when to check in with them more than once).

I was recently getting hobo glyphs for a level 25 character who hadn't done any of the Epic weapon quest (although he had one from previously); he had to visit his guild's appropriate person three times to unlock the Fun House.

@Bale: hehehe. Or, as they say in Korea, kekeke.
 
Top