This module supports up to 99 analog style counters:
(https://dl.dropbox.com/u/995571/examples.gif)
Usage:
To add a counter to the game, first define a global integer variable using the Global Variables pane (or the import/export method).
Then call
VARIABLE = CreateCounter();
The next step is setting up the counter. Add a Gui, then call:
Counter[VARIABLE].Setup(GUI*gui_to_use, int width_in_digits, int initial_value = 0, int delay = 5);
The Gui is resized automatically, initial_value and delay are optional.
A delay value of 5 is pretty slow, use lower values to make it faster. (5 means the counter is scrolled by one pixel every five frames, -2 will scroll the counter by 3 pixels every frame).
To change the default appearance (see first example image), use
Counter[VARIABLE].SetAppearance(FontType font, int font_color, int bg_color);
The border is drawn using the font color.
To set/scroll the counter, there are three possibilities:
Counter[VARIABLE].SetValue(int v);
.ScrollBy(int by);
.ScrollTo(int target);
SetValue changes the counter immediately to
v, ScrollBy scrolls
by times, ScrollTo scrolls to
target. Obviously, ScrollBy() allows for negative values. Currently, it's not possible to scroll below 0 or above 10^digits-1 though.
Possible future features:
-support putting counters on Gui buttons
-allow for negative values
-change counter array to instances
-expand appearance settings
DOWNLOAD MODULE (http://dl.dropbox.com/u/995571/ScrollingCounter.scm)
Nice.
Simple.
Useful.
Good stuff. :)
Looking great and might be useful one day.
Thanks!