ZLib -- Zarqon's useful function library

Doc

New member
Thank you, and sorry. I don't know much about .jar files so I was thinking that the EXE was the only option :p
 

StDoodle

Minion
As mentioned here (in case you miss it) it may be a good idea to change line 353 from
Code:
if (!to_boolean(vars["automcd"]) || (my_ascensions() < 1)) return true;
to
Code:
if (!to_boolean(vars["automcd"]) || (my_ascensions() < 1) || in_bad_moon()) return true;
to help out all the BM folks.
 

zarqon

Well-known member
Good idea; changed locally. Waiting on some time to implement the changes to has_goal() before updating.
 

tyilo

Member
I get an error when running it: Function 'item_drops_array( monster )' undefined (zlib.ash, line 218)
why?
 
Z, could you add a combat filter option to the obtain function please.

Suggested change:

Code:
boolean obtain(int n, string cond, location locale, string filter) {
   if (cond == "choiceadv") cli_execute("conditions clear; conditions add "+n+" choiceadv");
   else {
      if (retrieve_item(n, to_item(cond))) return vprint("You have "+n+" "+cond+", no adventuring necessary.",5);
      if (!in_hardcore() && storage_amount(to_item(cond)) > 0) take_storage(n-have_item(cond),to_item(cond));
       if (have_item(cond) >= n) return vprint("You have taken your needed items from storage.",5);
      cli_execute("conditions clear");
      add_item_condition(n - have_item(cond), to_item(cond));
   }
   set_location(locale);
   if(length(filter) > 0){ if(adventure(my_adventures(), locale, filter)) return vprint("Out of adventures.",-1); }
   else if (adventure(my_adventures(), locale)) return vprint("Out of adventures.",-1);
   if (cond == "choiceadv") return (my_adventures() > 0);
   return (have_item(cond) >= n);
}
boolean obtain(int n, string cond, location locale) { return boolean obtain(n, cond, locale, ""); }
That would be wonderful. :)
 

zarqon

Well-known member
Like it, added locally (and thanks for making it easy). Just because I've never used combat filters doesn't mean the flexibility wouldn't be nice!
 
Thanks for adding this. I just learned about combat filters last week and have already found several uses for them. They can be pretty handy.

The last line in the code I posted should be:
Code:
boolean obtain(int n, string cond, location locale) { return obtain(n, cond, locale, ""); }

I'm sure you already changed it.
 
Mostly for quest scripts, to fight the bosses, so a CCS doesn't have to handle it. That way, I know the script will handle a specific fight in a particular way regardless of what's in the CCS. I recently used it with obtain when I scripted the Nemesis Volcano quest. That way, no matter who runs the script or what their CCS contains, I know that the slime vials will drop because the filter ensures that the bottle of Gu-gone is being used.

Also, sometimes I want to use items in a particular fight only if I have them in inventory, but if I don't have them in inventory, I still want the fight to proceed as normal. Combat filters make that easy, without having to write and set a custom combat script.
 
Last edited:

catatonicmonkey

New member
Getting an error whenever I try to run any script or library that calls zlib. Any help?

Code:
> call scripts\zlib.ash

Expected ;, found + (zlib.ash, line 222)
 

slyz

Developer
The KoLMafia forum went down today for about an hour, and scripts using ZLib's check_version() for the first time in that time hanged. Could ZLib detect this and skip version checking for the day when this happens? It's only a small change:
PHP:
void check_version(string soft, string prop, string thisver, int thread) { int w;
   switch (get_property("_version_"+prop)) {
      case thisver: return;
      case "": vprint("Checking for updates (running "+soft+" ver. "+thisver+")...",1);
         string forum = visit_url("http://kolmafia.us/showthread.php?t="+thread);
		 if ( forum == "" ) { vprint("Connection problem: version will not be checked again today",-1); set_property("_version_"+prop,thisver); return;  }
         matcher find_ver = create_matcher("<b>"+soft+" (.+?)</b>",forum); w=19;
         if (!find_ver.find()) { vprint("Unable to load current version info.",-1); return; }
         set_property("_version_"+prop,find_ver.group(1));
         if (find_ver.group(1) == thisver) { vprint("You have a current version of "+soft+".",1); return; }
      default:
         vprint_html("<big><font color=red><b>New Version of "+soft+" Available: "+get_property("_version_"+prop)+"</b></font></big>",1);
         vprint("Upgrade "+soft+" from "+thisver+" to "+get_property("_version_"+prop)+" here: http://kolmafia.us/showthread.php?t="+thread,"blue",1);wait(1+w);
   }
}
 

zarqon

Well-known member
This wouldn't really save much time for most scripts -- visit_url() will still have to time out first. But I suppose a day's delay on updates is better than waiting for the timeout every combat in the event that you have check_version() happening in a consult/betweenBattle script. I'll put it in.
 

syrinxlui

Member
I'm trying to run Zarqon's MacGuffin.ash and get this error:
Function 'vprint( string, int )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts. (macguffin.ash, line 31)

It seems like mafia doesn't recognize that I have zlib.ash. I have downloaded zlib.ash and it's in my scripts directory with macguffin.ash. I don't have other versions of zlib.ash laying around. I get the error both with mafia 14.1 and a daily build 8544. Any help with this is greatly appreciated.
 

Bale

Minion
Nope. No subfolders (of the scripts directory). No older versions.

If you had downloaded an older version of zlib to your /relay directory it will run from there also. It might even be found, and imported from /data. make sure you don't have it ANYWHERE, because I'd swear from your error that you've got an out of date copy of zlib SOMEWHERE.
 

Xireph

New member
I'm trying to run a script that calls on this, and I keep getting the error message:
function 'item_drops_array( monster )' undefined (zlib.ash, line 218).
I opened the script in kate, and low and behold there was a function 'item_drops_array( monster )', but it didn't seem particularly more defined or undefined than anything else (here I speak with no knowledge). Any recommendations?
 
Top