Zlib

From Kolmafia
Revision as of 23:17, 28 November 2010 by imported>StDoodle
Jump to navigation Jump to search


Behold, a single function library containing most of zarqon's most useful functions, which will be used by most of his scripts. He grew tired of tweaking a function that was in multiple scripts and making sure he had changed them all. It would be nice, he thought in his customary italics, to have it in just one place.

In choosing which functions to include, he have tried to select only those functions which are a) super useful, or 2) needed by another of the included functions. It's a bit less efficient in terms of individual scripts, but in terms of repeated code across a family of scripts it is far simpler.


string excise(string source ,string start ,string end )

  • The original source string
  • start after this string
  • end before this string

This function returns a portion of the source string, from after the first occurrence of start to just before the first occurrence of end. If either start or end are missing, it will return an empty string. You can also supply either start or end as blank strings to specify the actual start or end of the source string.


string normalize(string mixvar ,string type )

  • mixvar is the string to normalize
  • type is the datatype to normalize to

Returns mixvar, normalized to the specified mafia type, which can be any primitive type or ASH datatype constant. For example, normalized("badger", "familiar") would return "Astral Badger".


More Information

See the thread for ZLib on the mafia forum here.