where to place global functions

Started by Theme, Sat 30/07/2005 21:46:06

Previous topic - Next topic

Theme

// 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/

DoorKnobHandle

Placing function there is perfectly fine. I never saw a reason to NOT put functions there to be honest.


monkey0506

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...

RickJ

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.   

SMF spam blocked by CleanTalk