Get Flat Icon

by DarkCampainger
[Share] [Zip]
ID:112194
 
Want to show your player's icon in the browser or output control? Frustrated that only their base icon--and none of their overlays or underlays--are included?

This library flattens any object's icon into a single dynamic icon at runtime. The icon can then easily be shown in a browser, output, or even a label!

The library fully supports all types of overlays: icon files, icon states, objects, object types, images, dynamic icons, and images with dynamic icons. It correctly handles inheriting the icon, icon_state, and dir from the base mob; as well as FLOAT_LAYER. It can even handle pixel_x/y values that move overlays outside of the base icon's bounds!

As a cherry on top, the library has a fully functional cache, so you don't have to worry about keeping track of a reference to the flattened version of the icon.

To use it, you just have to call one simple function:

getFlatIcon(atom/A, dir, cache=1)
Return value: /icon object
Parameters:
  • atom/A - the atom you want a flattened icon of
  • dir - the direction you want the atom rendered in (defaults to current direction)
  • cache - determines how the cache is used (default 1)
    • 0 - Cache is ignored and not written to
    • 1 - Cache is checked
    • 2 - Cache is not checked, but generated icon is written to it

Update History:

Version 1 (December 27th, 2011)

Improved the handling of directions

Changed internal variable names to make them more readable

Version 0 (May 31th, 2011)

Initial release
Awesome library.