[PLUGIN] AGS_TimerHelper plugin v1

Started by helios123, Wed 08/12/2010 17:53:37

Previous topic - Next topic

helios123

Hi all,

My second AGS plugin. Like the previous one, this is also open-source.
Main details are as below:

Description:

This plugin will add a method called a script GetTimerID and a define a macro
AGS_TIMERHELPER_IS_ACTIVE.

NOTE: The macro is named as <DLL name>_IS_ACTIVE. This is done in order to
guarantee uniqueness, as there can be only one AGS_TimerHelper.dll in
AGS's root directory.


The documentation of GetTimerID is as below:

int GetTimerID()

Gets an available id which can be used for subsequent calls to SetTimer.
If all timers are currently in use, then it returns -1.


Inspiration:

I got the idea for developing this plugin while writing some code involving
SetTimer. Since currently the programmer has to choose a timer id, this can
create problems if SetTimer is being used in different pieces of code which
are being written by different programmers.

e.g. Suppose there are two modules using SetTimer. If, for some reason, both
of them are to be used in one game.
Also, consider that SetTimer is required in repeatedly_execute for some room
scripts. Then unless the timer ids in all places are different, there is
going to be unexpected behaviour.

Also, module writers cannot use SetTimer since they cannot decide which timer
id to choose. Even if they go on the safer side and choose one of the last
five ids (15 to 20), the game developer has to ensure that no two modules are
unintentionally using the same timer id.

Please note that this plugin is intended to be used only when SetTimer is
being called at more than one script, as described above.
If the use of SetTimer is limited to just room scripts, then this plugin is
not required.


Usage:

01. Put the AGS_TimerHelper.dll in the folder where AGS is installed.
02. Start AGS Editor and load/create a game. In the Right hand top pane under
"Plugins" right click on the dll name and select "Use this plugin".
03. Selecting "Plugin Properties" from the pop-up menu in step 2 will show
a detailed help dialog. Please refer it for help on using this plugin. Or you
can refer to the ReadMe_long.txt file included in this distribution.

AGS Version:

Tested with AGS version 3.2. But should work fine on older versions as well, since SetTimer is not a new function.

IMPORTANT NOTE:
This plugin was developed using the Code::Blocks IDE, with MS Visual C++ as
compiler. So the project file cannot be opened in Visual Studio. Create a blank DLL project and add the source files,
if using Vicual C++ IDE.


Comments and criticisms are always welcome.

Download here
That's all for now,
helios123

SMF spam blocked by CleanTalk