Module writing hints: Difference between revisions

From Adventure Game Studio | Wiki
Jump to navigation Jump to search
*>SSH
(Added dependency and naming collision sections)
(→‎Module licencing: pulbished -> published)
Line 43: Line 43:
== Module licencing ==
== Module licencing ==


[http://creativecommons.org/license/ Creative commons] have a custom licence generator where you can choose the terms you want. Other suggested licences are the MIT/BSD licence, which only requires acknowledgement of the author, and the LGPL licence which requires any changes made to be pulbished as open source.
[http://creativecommons.org/license/ Creative commons] have a custom licence generator where you can choose the terms you want. Other suggested licences are the MIT/BSD licence, which only requires acknowledgement of the author, and the LGPL licence which requires any changes made to be published as open source.


== Dependencies on GUIs ==
== Dependencies on GUIs ==

Revision as of 02:26, 8 December 2005

Module debugging

When debugging a module, you can create another dummy module earlier in the module list with something like this in its header:

  #define DEBUG_MYMODULE

Then, in the real module that you are working on, surround debug code with:

#ifdef DEBUG_MYMODULE
   // debug code, e.g. Display or labelDebug.Text=something
#endif

then, if you export the module and forget to remove the debug code, it won't affect the running of the module.

However, it is probably best if, before release, you always import a module into a fresh game so that you can check for any things like this, and other accidental dependencies.

Calling a user-defined function from a module

If you want to call a function that can have a default function, included in the module, but also want the user to be able to rewrite just that function, without having to edit your module then you can use this technique:

surround the default function with:

#ifndef MyModule_CustomFunction
function my_dialog_request (int arg) {
  // etc...
}
#endif

then, also provide an example module with a custom function in it:

function my_dialog_request (int arg) {
  // etc... custome version
}
#define MyModule_CustomFunction

which must come before the main module in the module list. This will allow the custom module to override the default if it exists, but if it is not there then the default is used. This might be used, for example, in an icon-based dialog module or similar.

Module licencing

Creative commons have a custom licence generator where you can choose the terms you want. Other suggested licences are the MIT/BSD licence, which only requires acknowledgement of the author, and the LGPL licence which requires any changes made to be published as open source.

Dependencies on GUIs

If your module depends on a particular GUI name, remember that AGS does a #define for GUI names, so that

   #ifndef MYGUI

will work. It's not foolproof, as a view with the same name might exist instead of the GUI, but its better than nothing.

Name collisions

Beware of exporting any names from a module that are likely to be used as local variables in loops, whatever. This is why the Module programming guidelines sugegst prefixing them all with the module name, or using a struct, so that all exported identifiers are struct sub-members.