Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Theme on Sat 30/07/2005 21:46:06

Title: where to place global functions
Post by: Theme on Sat 30/07/2005 21:46:06
// Main header script - this will be included into every script in
// the game (local and global). Do not place functions here; rather,
// place import definitions and #define names here to be used by all
// scripts.

where do i place the functions them?

o/
Title: Re: where to place global functions
Post by: DoorKnobHandle on Sat 30/07/2005 21:47:36
Placing function there is perfectly fine. I never saw a reason to NOT put functions there to be honest.
Title: Re: where to place global functions
Post by: Theme on Sat 30/07/2005 21:58:06
oh, thanks [...]

o/
Title: Re: where to place global functions
Post by: monkey0506 on Sat 30/07/2005 23:53:50
Well the preferred method is to place:

import function func_name(func_params, ...);

In the header, and then:

function func_name(func_params, ...) {
  /* func_def */
  }

In the corresponding script.  For example, the main or global script header should contain imports for functions that are declared in the global script.

Not quite sure if there's a difference...but it says not to place the function definitions in the header...
Title: Re: where to place global functions
Post by: RickJ on Sun 31/07/2005 01:24:33
The compiler copies the header into each room script and the global script whenever it runs.   In this casewhenever a change is made to the header then every room script would have to be recompiled.    This is the reason it is not recommended.