OnModuleLoad

From NWN Lexicon
Jump to navigationJump to search

The script attached to this event fires when the module is first loaded from a new game or from a save game. This is a good place to initialize any variables that need to be initialized.


Trigger

When a module is initially loaded from a new game or a save game.


Remarks

For 1.60+, for new modules a default script called x2_mod_def_load will be put in this event hook, which is required for Use Magical Device settings to be set, as well as other module settings. This is not required, however.

Do note that since the event can run twice you might want to note if it has run and not run some aspects (eg default quest variables) a second time, potentially stripping progress from the player.

To note it's running from a save game set a variable such as "DONE_MODULE_LOAD" and check for it, alternatively the check "if (GetIsObjectValid(GetFirstPC()))" will mean it is save game since the PC isn't valid when it's a new module start.