Neverwinter Vault

Expand AllContract All -Site -My Profile -Features

Neverwinter Nights 2

-NWN2 Files -NWN2 Game Info -NWN2 Resources -NWN2 Community

Neverwinter Nights

-NWN Files -NWN Game Info -NWN Resources -NWN Community

Vault Network
RPG Vault
VN Boards
IGN Vault
Vault Wiki
· Age of Conan
· Anarchy Online
· Asheron's Call
· Dark Age of Camelot
· City of Heroes
· D&D
· EVE Online
· EverQuest
· EverQuest 2
· Final Fantasy
· Guild Wars
· Lineage 2
· Lord of the Rings Online
· Middle Earth
· Neverwinter Nights
· Pirates of the Burning Sea
· Rise of the Argonauts
· Star Wars Galaxies
· Tabula Rasa
· The Matrix Online
· The Witcher
· Titan Quest
· Two Worlds
· Vanguard
· Warhammer
· World of Warcraft

Planet Network
Planet Hub

IGN
Games
Cheats
Entertainment

The Web   The Site  



NWN2 SCRIPTS

- Jump to comments -
Name  Script Execution Library
Author  jallaix
Submitted / Updated  09-07-2007 / 09-07-2007
Category  Scripting routines
Type  Type - General
Format  Code Only
Patch  1.06
Description
This library provides functions to execute scripts in an extended way, as an alternate mean to call functions.
First you can pass parameters to a script that's going to be executed (int, float string, object location, itemproperty).
Then you can call the script using a fork system (thanks to Yaballa for her subscript pattern).
Finally get the returned value from the calling script (int, float string, object location, itemproperty).

This system has many advantages:
* Makes your code easier to maintain
* Improves script performance
* Permits to override functions
* Increases compatibility between different systems
* Improves module organization

Maintenability
--------------
Let's assume you wrote a function in an include file.
This include file is included by many other scripts that use this function.
If you modify this function, you have to recompile all the scripts that use it.
Instead export the code of this function in an external script, and simply call this script from your function.
The next time you'll modify this function, in fact you'll just modify the called script and compile it.

Performance
-----------
So you've exported the function's code to the external script.
All scripts that use the include file do not include the function's code when compiling.
So it takes less memory when the scripts are loaded.

Function override
------------------
As the function's code is now in an external script file,
it's possible for anybody to customize it without recompiling the scripts that use this function.
You can compare this functionality with what is provided in object-oriented programming languages like Java.

Compatibility with other systems
--------------------------------
When distribute your scripts, follow this process :
Don't include your external script in a hak, instead put it in an erf that will be imported in a module.
Other systems will be able to rewrite your scripts and make them compatible with yours.

Module organization
-------------------
Use the fork script system to group all your external scripts in only one.
It's easier to manage one file than many.

Limitation
----------
You can only pass parameters of the following type :
int
float
string
object
location
itemproperty



Example 1 : "calling_script.nss"
---------
float function CallingFunction(object oObject, int iInteger, itemproperty ipItemProp)
{
// Declare the list of parameters
struct script_param_list paramList;

// Add parameters to the list
paramList = JXScriptAddParameterObject(paramList, oObject);
paramList = JXScriptAddParameterInt(paramList, iInteger);
paramList = JXScriptAddParameterItemProp(paramList, ipItemProp);

// Call the script with the fork system
JXScriptCallFork("called_script", 3000, paramList);

// Get the response from the called script
return JXScriptGetResponseFloat();
}

Example 2 : "called_script.nss"
---------
void main()
{
struct script_param_list paramList = JXScriptGetParameters();
int iOperation = JXScriptGetForkOperation();

switch (iOperation)
{
case 3000 :
// Get the parameters from the list
object oObject = JXScriptGetParameterObject(paramList, 1);
int iInteger = JXScriptGetParameterInt(paramList, 1);
itemproperty ipItemProp = JXScriptGetParameterItemProp(paramList, 1);

// Do whatever you want here, you can even call JXScriptCallFork() once again !

// Set the response of the script
JXScriptSetResponseFloat(12.569);
return;
}
}

Files

NameTypeSizeDownloads
Script_Execution_Library.zipScript_Execution_Library.zip
Submitted: 09-07-2007 / Last Updated: 09-07-2007
zip5.49Kb165
Contains "jx_inc_script_call.nss" and "jx_inc_data_func.nss"
SCORE OUT OF 10
10
1 votes
View Stats
Cast Your Vote!
Voting FAQ

PORTFOLIO
Add this entry to your portfolio so you can track it
Manage your existing portfolios or create a new one.
SCREENS
No Images




You Must Be Logged In to Participate.
Comments (2):

Posted by jallaix at 2007-09-13 04:08:26    
Thanks for your feeback !
I don't think I'll spotlight this as it doesn't seem to interest many people. Anyway I don't know how to ask ;-)
_________________________
Spellcasting Framework
Wild/Dead Magic Zone (Spellcasting Framework add-on)

Posted by Yaballa at 2007-09-12 23:17:33    Voted 10.00 on 09/12/07
This is fantastic and should be proposed as a standard. Ask Maximus to spotlight this :)

You must be Logged In to post comments in this section.

10 - A Masterpiece, Genuinely Groundbreaking
9 - Outstanding, a Must Have
8 - Excellent, Recommended to Anyone
7 - Very Good, Deserves a Look
6 - Good, Qualified Recommendation
5 - Fair, Solid yet Unremarkable
4 - Some Merit, Requires Improvements
3 - Poor Execution, Potential Unrealized
2 - Very Little Appeal
1 - Not Recommended to Anyone

 
Most recent posts on the MMO General Boards
Analyst: Star Wars: The Old Republic Could...Analyst: Star Wars: The Old Republic Could Sell 3M: more numbers
- last reply by Acao on Aug 15, 2011 06:15 PM
which class will your first character be
- last reply by Blisteringballs on Aug 15, 2011 05:50 PM
New Community Content!
- posted by Vault_News on Aug 15, 2011 05:00 PM
New Community Content!
- posted by Vault_News on Aug 15, 2011 04:00 PM
NWN Idea Database Update
- posted by Vault_News on Aug 15, 2011 03:46 PM
Missing Votes for NWN2 Hall of Fame
- posted by Vault_News on Aug 15, 2011 03:40 PM
Missing Votes for NWN Hall of Fame
- posted by Vault_News on Aug 15, 2011 03:39 PM
Random Questions and game altering suggest...Random Questions and game altering suggestions!!!
- last reply by ArkadyTepes on Aug 15, 2011 03:22 PM
State of the game?
- last reply by LyricOpera on Aug 15, 2011 01:37 PM
Yesterday streaming, now demanding downloa...Yesterday streaming, now demanding download :(
- last reply by Sinane-tk on Aug 15, 2011 10:23 AM
 

   


IGN Entertainment
By continuing past this page, and by your continued use of this site, you agree to be bound by and abide by the User Agreement.
Copyright 1996-2011, IGN Entertainment, Inc. | Support | Privacy Policy | User Agreement | RSS Feeds
IGN’s enterprise databases running Oracle, SQL and MySQL are professionally monitored and managed by Pythian Remote DBA.


NWN2 Hall of Fame

HOF NWN2 Models


View all Hall of Fame entries


Neverwinter Nights 2

TOP NWN2 Modules

NEW Modules

NEW Reviews

NEW INTL. Modules

TOP Hakpaks

TOP Gameworlds

TOP Tutorials

TOP Prefab:Areas

TOP Blueprints

TOP Plugins

TOP UI

TOP Other

TOP Visual Effects

TOP Scripts

TOP Tools

TOP Movies

TOP Models

TOP Characters





Hall of Fame

HOF NWN Modules


View all Hall of Fame entries


TOP NWN Modules

NEW NWN Modules

NEW Reviews

TOP Intl. Modules

TOP NWN Hakpaks

TOP NWN Gameworlds

TOP NWN Models

TOP NWN Portraits

TOP NWN Scripts

TOP NWN Prefabs

TOP NWN Other

TOP NWN Movies

TOP Sounds

TOP NWN Textures

TOP NWN Creatures

TOP NWN Characters