|
|
Home Forum Index Neverwinter Nights 2 NWN2: Builders - NWN2 Scripting The scope of variables
NWN2: Builders - NWN2 Scripting
KublaKhan1797
Game Owner
NWN NWN: SoU Jade Empire:SE NWN 2 Mass Effect PC
Joined: 03 Jan 2007 |
Posted: Thursday, 04 January 2007 12:40PM |
I have just started scripting a little and I'm rather confused about the scope of variables - or more precisely the difference in scope of global and local variables.
I'm guessing globals are persistent across areas (and modules?) - but what about local variables are they only persistent during the execution of a single script? Also is it necessary to declare a global via SetGlobalXX() or will it automatically be declared with a default value if referred? And when I'm done with a global variable how do I finalize it to prevent memory leakage?
I apologies in advance if this has been asked and answered a thousand times before, I looked about for the information but couldn't find it. |
|
ScarfaceDM
Game Owner
NWN NWN: SoU NWN: HotU NWN 2
Joined: 07 Oct 2006 From: From England, Living in Sweden. |
Posted: Thursday, 04 January 2007 03:28PM |
A standard variable defined outside (and above) any function or void main will be global within that script, a standard variable defined within a function or void main will not be global within that script, it will be usable within the function or void main that it was defined in.
A local variable is stored on an object and is retrievable from any script as long as it exists, they are not persistent unless stored on items in a PCs inventory and then the PCs character exported.
A global variable is not persistent in any way, it is simply 'global', it is not stored on any object thus making it retrievable via its sVarName and not from an object.
A campaign variable is stored in the database folder in your NWN2 directory and also not on any object, and is persistent and retrievable from any script as long as it exists. _________________ Chaotic World Final NWVault Hall Of Fame Rank #3 |
|
|
Search Forums |
Forums FAQ |
Forum Archives
|
NeverWinter Nights 2, Forgotten Realms and the Forgotten Realms logo, Dungeons & Dragons, D&D, and the Dungeons & Dragons logo, and Wizards of the Coast and its logo are trademarks of Wizards of the Coast, Inc., in the U.S.A. and other countries, and are used with permission. © 2004 Wizards. Software © 2004 Atari Interactive, Inc. All rights reserved. HASBRO and its logo are trademarks of Hasbro and are used with permission. Windows is either a registered trademark or trademark of Microsoft Corporation in the United States and/or other countries. Manufactured and marketed by Atari, Inc., New York, NY. All other trademarks are the property of their respective owners.
Powered by BioBoards Version 3.00.0 10.1.12.31
Web Site Help
Jobs | Website Terms of Use Agreement | Privacy Policy
Rules of Conduct | Copyright and Trademark Information
|
|