Demo implementation included.
////////////////////////
// //
// STAT BAR OVERLAYS //
// VERSION 0.6 //
// BY DARKCAMPAINGER //
// //
// REFERENCE //
// //
////////////////////////
//
// > Create a new bar overlay
//
new/bar_overlay(atom/owner, icon, states, var_stat, var_max, \
layer=FLOAT_LAYER, pixel_x=0, pixel_y=0, state_prefix="", \
timeout=0, auto_show=null, hide=null)
//
// > Arguments: (supports named arguments)
//
// - owner: the atom the bar is attached to
// - icon: icon to use for the bar
// - states: number of states, or levels, in the icon (optional)
// - var_stat: name of the variable that holds the stat
// - var_max: name of the variable that holds the stat's max value
// - (layer): layer to place the bar on (optional)
// - (pixel_x): pixel_x offset of the bar (optional)
// - (pixel_y): pixel_y offset of the bar (optional)
// - (state_prefix): prefix for bar's icon_states (optional)
// - (timeout): number of ticks to auto-hide bar after (optional)
// - (auto_show): whether to show bar on calls to Update() (optional)
// - (hide): whether to initially hide bar on creation (optional)
//
// All properties (except owner) can alternatively be defined at compile-time
// under a /bar_overlay subtype, at which point they become optional above
//
// > Returns:
//
// New bar_overlay attached to the specified owner, displaying percentage
// of [var_stat]/[var_max]. Uses states "[state_prefix]1" through
// "[state_prefix][states]" of [icon].
//
// > Update an existing bar overlay
//
bar_overlay/Update(_unused=null, force_show=null, force_timeout=null)
//
// > Arguments:
//
// - [_unused]: previously force_update, no longer needed, left for
// backwards compatibility
// - [force_show]: set to a true value to force the bar to be shown even
// if it is currently hidden (overrides bar's auto_show var)
// - [force_timeout]: set to number of ticks to timeout after and auto-hide
// (overrides bar's timeout var)
//
// > Show a bar overlay
//
bar_overlay/Show(force_timeout=null)
//
// > Arguments:
//
// - [force_timeout]: set to number of ticks to timeout after and auto-hide
// (overrides bar's timeout var)
//
// > Hide a bar overlay
//
bar_overlay/Hide()
//
//
Update History:
- Version 0.6 (October 5th, 2013)
- Fixed bug where calling Show() wouldn't have any effect if Update() hadn't been previously called
- Deprecated Update()'s force_update argument, as it no longer had any effect
- Version 0.5 (October 5th, 2013)
- Fixed bug where a stat bar wouldn't check if its owner still existed before triggering a hide timeout
- Version 0.4 (August 11th, 2012)
- Fixed bug where auto_show and _hidden were not being correctly determined based on timeout
- Moved and renamed demo icons so they're less likely to interfere with projects
- Version 0.3 (March 26th, 2012)
- Library now supports defining stat bar properties at compile-time by making a subtype of /bar_overlay (see mana_bar in updated demo)
- Library can now determine the number of icon_states for a stat bar if it is not provided
- Version 0.2 (November 12th, 2011)
- Added Show() and Hide() functions
- Added timeout, auto_show, and hide arguments to New()
- Renamed Update()'s force argument to force_update
- Added force_show and force_timeout arguments to Update()
- Updated demo to demonstrate new timeout feature
- Version 0.1 (June 5th, 2011)
- Library renamed from "Quick Overlay Stat Bars" to "Stat Bar Overlays"
(Suggested you Uninstall and then re-Download the library to prevent old files from lingering)- Naming conventions brought in line with BYOND's
This will require some quick changes, which you can do with Find/Replace (Ctrl+H)
- overlayBar -> bar_overlay
- update() -> Update() (Be careful! Use Find Next to first check that it's the Update() for a /bar_overlay)
- varStat -> var_stat (shouldn't be necessary unless you directly accessed a bar)
- varMax -> var_max (same are above)
- Stat bar overlay is now automatically removed when the /overlayBar is deleted
- Changed default layer to FLOAT_LAYER
- New property: state_prefix. Allows you to store multiple bar images in one icon file, by giving them a prefix (eg "health1","health2", ect)
- New optional parameter for Update(): force. Forces the bar to update, even if nothing has changed. Useful when rebuilding overlay lists. Defaults to 0.
- Added reference to library's code file.
- Version 0.0 (May 31st, 2011)
- Initial release
"This should be used as the new standard for overlay bars."
Thank you very much for this library.