ZLib -- Zarqon's useful function library

Yeah, I think a vprint_html() is quite doable. This will be in the next update -- which will also add Map Manager to ZLib!!11!!1!!11! Thanks to Veracity implementing her own great idea to make this work.

Conceptually, I think you should replace every instance of print(), so that people can set verbosity to 0 to see strictly mafia-generated output. I think a level of 1 would be fine for that. (The version-checking function also has a level of 1.)
 
Last edited:
test.ash:

Code:
import <test2.ash>

boolean vprint2(string message, string color, int level) {
	if (level == 0) { print(message,"red"); exit; }
	if (to_int(vars["verbosity"]) >= abs(level)) print(message,color);
	return (level > 0);
}
boolean vprint2(string message, int level) {
	if (level > 0) return vprint2(message,"black",level);
	return vprint2(message,"red",level);
}

void main() {
	boolean vprint3(string message, string color, int level) {
		if (level == 0) { print(message,"red"); exit; }
		if (to_int(vars["verbosity"]) >= abs(level)) print(message,color);
		return (level > 0);
	}
	boolean vprint3(string message, int level) {
		if (level > 0) return vprint3(message,"black",level);
		return vprint3(message,"red",level);
	}
	vprint("1",6);
	vprint("trying to exit",1);
	if ( exitScript() ) {
		vprint("Exiting didn't work",1);
	}
	vprint("Trying again",1);
	vprint("Exiting script...",0);
	vprint("3",6);
	vprint("Trying again without importing",1);
	vprint2("Exiting script...",0);
	vprint("4",6);
	vprint("Trying again with same level vprint",1);
	vprint3("Exiting script...",0);
	vprint("5",6);
}

test2.ash:
Code:
import <zlib.ash>

boolean exitScript() {
	vprint("Exiting script...",0);
	vprint("2",6);
	return true;
}

gCLI output:
Code:
> call test

1
trying to exit
Exiting script...
2
Exiting didn't work
Trying again
Exiting script...
3
Trying again without importing
Exiting script...
4
Trying again with same level vprint
Exiting script...
5

Looks like it doesn't work.

EDIT: I added vprint(string, string, level) for use by vprint2 and vprint3. Still doesn't work though.
 
Last edited:
Well, that fails to delight my soul. Looks like it's back to abort() for the next ZLib.

Thanks for figuring that out, slyz.
 
'exit' won't break out of a function whose return value is used in any way. It's exactly the same mechanism that allows errors in built-in functions to be captured by doing something with their return value.
 
error using zlib

Hey kids... I've loaded the newest version of zlib.ash, and I'm getting the following error message whenever I try to adventure:

Expected ), found aggregate (zlib.ash, line 146)

I'm using FirstThingsFirst, SmartStasis, and have BestBetweenBattle set as my betweenBattleScript.

Is there a quick fix for this? I don't have a text editor with line numbering on this computer, so I can't tell where the error is occurring.
 
So I've tried posting this in another thread for a ash that uses zlib, but I think this is the correct thread.

But what value would I put for a familiar to have it stay instead of change.

ocw_f_arena
ocw_f_default Ninja Pirate Zombie Robot
ocw_f_farm
ocw_f_junkyard
ocw_f_lighthouse jumpsuited hound

So there are even several that are blank, but it won't let me leave those 2 blank, and if I do it just resets them to these two default familiars.

So I'm just looking for a value to have it not change my familiar?

Thanks
 
The script is not designed to handle blank values, but there is a way around it by specifying a familiar for is_100_run. Note that this will lock your familiar for all scripts that use ZLib, and you will be unable to adventure with a different familiar until you reset is_100_run to "none".
 
ZLib 15 Updates

  • Added some nifty functions which make use of the use_for_items map put together by aqualectrix for her PriceAdvisor script: has_goal(item) and has_goal(monster). (See the first post for return values/explanation.) These useful functions will be making their way into BBB and FTF, making them much more thorough in their detection of goals / use of container items. Thanks aqualectrix!

    Note to authors concerned about bloat: the map is only loaded if the function is called, and only once per ZLib instance.
  • vprint(message,0) is back to using abort() rather than exit. Exiting seemed desirable since if a script exited, operation could continue. However, exiting failed if the return value of vprint() was captured, which was quite often the case since it was written as a way to return a boolean along with providing customizable user feedback. Thus, I encourage script authors to reserve vprint(msg,0) for situtations where all operation should stop, such as an error eating in your breakfast script, or an error loading a data file that your routine script needs for its daily adventuring.
  • As forewarned over a month ago, this version of ZLib removes error(), which was deprecated by the superior vprint().
 
I think V15 has broken things in other scripts. I went to run farm.ash and got this pretty much immediately:

Function 'error( string )' undefined (canadv.ash, line 38)

Also in woosname:

Function 'error( string )' undefined (Wossname.ash, line 402)

I updated up to mafia 8096 and still got the same thing.

This was in two different multis.
 
ZLib 15 Updates

  • As forewarned over a month ago, this version of ZLib removes error(), which was deprecated by the superior vprint().

EDIT: you have to replace error(string); by vprint(string,-2);

EDIT2: fixed the change as per Zarqon's advice. I thought error was an abort =)
 
Last edited:
I've already updated Wossname today -- there were a few residual error() references that I'd missed. I believe the current version of CanAdv also has no problems -- might want to re-download just to make sure.

EDIT: slyz's fix is close -- but if you use 0 it will be an abort message and the script will stop. If you're converting error() to vprint() you should instead change it to vprint(message,-2) as a general starting point. Larger numbers for less important messages.
 
Last edited:
I have updated both canadv.ash and OCW. Both are running happily now.

Thanks for all your scripts (I use several) and the quick response.

You acquire an item: Order of the Silver Wossname
Victory! Veni, vidi, vici and all that stuff.
 
Last edited:
Code:
boolean vprint(string message, string color, int level) {
   if (level == 0) [COLOR="Red"][B]abort[/B][/COLOR](message);
   if (to_int(vars["verbosity"]) >= abs(level)) print(message,color);
   return (level > 0);
}
boolean vprint(string message, int level) { if (level > 0) return vprint(message,"black",level); return vprint(message,"red",level); }
boolean vprint_html(string message, int level) {
   if (level == 0) { print_html(message); [COLOR="Red"][B]exit;[/B][/COLOR] }
   if (to_int(vars["verbosity"]) >= abs(level)) print_html(message);
   return (level > 0);
}
I think you forgot to update vprint_html().
 
I'm sure I have no idea what you're talking about. In fact, I'm pretty sure you only imagined that.

;)
 
Back
Top