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  List Functions 1.02
Author  WizardStorm Think Group
Submitted / Updated  01-08-2007 / 09-25-2007
Category  Scripting routines
Type  Type - Other
Format  Code Only
Patch  1.07
Description
Version 1.03
Added an additional function called ListCompare.

========= ========== =========== =========
Version 1.02
Bug Fixes and such.

========= ========== =========== =========
Version 1.01

WizardStorm Think Group is pleased to present to you three addional String Functions
and nine new List functions. We think you will find these functions invaluable in your
future projects. Enjoy!!!

If you find any bugs or want to suggest adding something to this library,
please post below or send an email to [email protected]

/****************************************
STRING FUNCTIONS
****************************************/
//Description: Removes the leading/trailing spaces from either the LEFT,
//RIGHT or BOTH ends of a sString. Default = BOTH.
//Returns: A copy of sString with the specified end trimmed of leading/trailing spaces.
string GetStringTrim(string sString, string sTrimEnd="BOTH");


//Description: Extracts a SubString from a String.
//Returns: A string; the set of characters from sString, beginning at nStart,
//of length nCount.
string GetStringMid(string sString, int nStart, int nCount);


//Description: Replaces all instances of sOldSubString with sNewSubString.
//By default, this is Case Sensitive, but this can be set to be Non-Case Sensitive.
//Returns: A copy of sString with all instances of sOldSubString replaced with sNewSubString.
string StringReplaceAll(string sString, string sOldSubString, string sNewSubString, int nCaseSensitive=TRUE) ;

/****************************************
LIST FUNCTIONS
****************************************/
//Descrption: Gets the first element of a list.
//Returns: The first element of a list. If the list is empty, returns an empty string.
string ListGetFirst(string sList, string sDelimiters=",") ;


//Descrption: Gets the last element of a list.
//Returns: The last element of a list. If the list is empty, returns an empty string.
string ListGetLast(string sList, string sDelimiters=",") ;


//Descrption: Gets the number of elements in a list.
//Returns: The number of elements in list.
int ListLen(string sList, string sDelimiters=",") ;


//Descrption: Gets the list element at a specified index.
//Returns: The element at a specified index. If element is empty at the specified index,
//returns a empty string.
string ListGetAt(string sList, int nIndex, string sDelimiters=",");


//Descrption: Inserts an element at the end of a list.
//Returns: A copy of the list, with sValue appended.
string ListAppend(string sList, string sValue, string sDelimiters=",");


//Descrption: Inserts an element at the beginning of a list.
//Returns: A copy of the list, with sValue inserted at the first position.
string ListPrepend(string sList, string sValue, string sDelimiters=",");


//Descrption: Deletes the element from a list at the specified index.
//Returns: A copy of the list, without the specified element.
string ListDeleteAt(string sList, int nIndex, string sDelimiters=",");


//Descrption: Inserts an element in a list at a specified index.
//Returns: A copy of the list, with the value inserted at the specified index.
string ListInsertAt(string sList, int nIndex, string sValue, string sDelimiters=",");


//Descrption: Replaces the contents of a list element.
//Returns: A copy of the list, with the new value assigned to the element at a specified index.
string ListSetAt(string sList, int nIndex, string sValue, string sDelimiters=",");


//Descrption: Changes a list delimiter.
//Returns: A copy of the list, with each delimiter character replaced with sNewDelimiter.
string ListChangeDelimiter(string sList, string sNewDelimiter, string sDelimiters=",");


//Descrption: Determines the index of the first list element that contains sSubString,
//not neccessarily equal to.
//If nCaseSensitive equals TRUE, the result will consider case in the search.
//Returns: Index of the first list element that contains sSubstring. If not found, returns 0.
int ListContains(string sList, string sSubString, int nCaseSensitive=TRUE, string sDelimiters=",");


//Descrption: Counts the instances of a specified value in a list.
//If nCaseSensitive equals TRUE, the result will consider case in the search.
//If nExactMatch equals TRUE, a list element must be an exact match to specified value.
//Else, the specified value can be within a list element.
//Returns: The number of instances that a list element equals sValue.
int ListValueCount(string sList, string sValue, int nExactMatch=TRUE, int nCaseSensitive=TRUE, string sDelimiters=",");


//Descrption: Determines the index of all list elements that contain the sSubString.
//If nCaseSensitive equals TRUE, the result will consider case in the search.
//If nExactMatch equals TRUE, a list element must equal the sSubString to be counted.
//If the sSubString is within the list element and nExactMatch equals FALSE,
//the list element is considered a match.
//Returns: Comma separated list of index values of the list elements that contains or
//is equal to the sSubstring.
//If not found, returns an empty string.
string ListFind(string sList, string sSubString, int nExactMatch=TRUE, int nCaseSensitive=TRUE, string sDelimiters=",");

Files

NameTypeSizeDownloads
wstg_list_functions.erfwstg_list_functions.erf
Submitted: 01-08-2007 / Last Updated: 09-24-2007
erf17.23Kb156
Version 1.03 - This ERF contains a single file containing the 3 String functions and 13 List functions. The most recent addition to the library is ListCompare. This new function compares two lists by method of "AND", "OR" or "XOR".
SCORE OUT OF 10
9.42
5 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 (13):

Posted by E.C.Patterson at 2007-12-17 10:13:07    Voted 8.50 on 12/17/07
Very useful, saved me a lot of time. Thanks for sharing.
_________________________
E.C.Patterson
Gaming Parents Studios

Trinity, the NWN2 adventure : Download now.

Posted by cricket at 2007-01-30 06:41:30    Voted 10.00 on 01/10/07
Correct me if I'm wrong, you are wanting a list function that performs an element override. So this 1 function could do the job of :
ListSetAt(sList,1,"6",",");
ListSetAt(sList,4,"3",",");
ListSetAt(sList,5,"2",",");
ListSetAt(sList,6,"75",",");

I kind-of see the point for this type of function but currently we will have to table this as a future enhancement due to other scripting priorities we are trying to accomplish.
Thanks for the input and ideas. Keep them coming!!!

SilentCricket

Posted by Urlord at 2007-01-30 05:06:49    Voted 10.00 on 01/09/07
Can you elaborate on when and how such a function would be used?
_________________________
Peace,

Jim
AKA Urlord

Visit the Persistent World of Nymri

Posted by Vanes at 2007-01-30 04:46:06    Voted 9.25 on 01/22/07
What I meant with that was that you would be able to fill in greater parts of a pre-existing list with more ease.

Say there's a list "1,2,3,4,5,6,7,8,9,10"

You 'paste' a string "6,,,3,2,75" to the list and it shows up as :
"6,2,3,3,2,75,7,8,9,10"

Umm, if you catch my drift. :)
_________________________
Logical arguments tend to favour those who have much faith vested in them. Often accompanied by an epic skill to resist the arguments against.

Posted by Vanes at 2007-01-30 04:40:15    Voted 9.25 on 01/22/07
How about a function that processes a string to a list ? Could be used to quickly set up a list without using the invidual functions in a loop as a bonus.

Something like : StringToList(string sString,string sList,string sDelimiters=",");
_________________________
Logical arguments tend to favour those who have much faith vested in them. Often accompanied by an epic skill to resist the arguments against.

Posted by Urlord at 2007-01-26 12:06:45    Voted 10.00 on 01/09/07
The latest version 1.02 has been uploaded. It corrects the bug found by Vanes as well as the three new List Funcrions.
_________________________
Peace,

Jim
AKA Urlord

Visit the Persistent World of Nymri

Posted by cricket at 2007-01-25 16:35:45    Voted 10.00 on 01/10/07
-- Vanes --
Thank you kindly for finding that critter and you are right. I failed to notice how it simply stuck it on the front and not do a replace. I've updated the code on our side and the new code should be posted tomorrow.
Included with the new updated code will be 3 new LIST functions: ListContains, ListValueCount, & ListFind.

Thanks again for the help.

Posted by Vanes at 2007-01-22 15:44:15    Voted 9.25 on 01/22/07
I figured it out finally. Either it's a slight mistake on your part or something but this fixed it for me :

In the ListSetAt() function, near the end it checks "if(nIndex == 1)" and if it is, just adds to the beginning of the list. So I changed this to read :


if(nIndex == 1)
{
sList = ListDeleteAt(sList,1,sDelimiters);
sList = ListPrepend(sList,sValue,sDelimiters);
return sList;
}

Now it will delete the first element and add the requested one as the first element, like it should. (In my mind)
_________________________
Logical arguments tend to favour those who have much faith vested in them. Often accompanied by an epic skill to resist the arguments against.

Posted by Vanes at 2007-01-22 14:42:39    Voted 9.25 on 01/22/07
I have but one problem with these list functions. Otherwise they're perfect !

If I want to add an element to the second place in the list for example, and the list for starters doesn't exist..how do I go about doing that ?

I'm trying to store a string to the first element and another to the second element and so on, and update them every once in a while. For some reason when I use 'ListSetAt' and select iIndex 1 for example, and the string is something like "0,1", it outputs it as "1,0,1" or something when I'd want it to make it "1,1". Aaghh, what am I doing wrong ?

I really like these list functions, don't get me wrong. :)
_________________________
Logical arguments tend to favour those who have much faith vested in them. Often accompanied by an epic skill to resist the arguments against.

Posted by puket at 2007-01-15 12:31:12    Voted 9.00 on 01/15/07
Solid work, keep up the good work, go further. Vote 9 is ok for me.

Posted by cricket at 2007-01-10 11:11:02    Voted 10.00 on 01/10/07
These list functions are great. They allow so much flexibility in the data that I can store. Retrieving the data is so much easier, too.

Posted by Urlord at 2007-01-09 20:20:50    Voted 10.00 on 01/09/07
Fixed a bug in ListGetAt() that was causing some wierdness when the elements were different lengths.
Please download the latest version.
_________________________
Peace,

Jim
AKA Urlord

Visit the Persistent World of Nymri

Posted by Urlord at 2007-01-09 15:13:33    Voted 10.00 on 01/09/07
This is the most useful set of functions I have ever seen. The more I use them the more uses I find for them. ABSOLUTELY AWESOME!!!
_________________________
Peace,

Jim
AKA Urlord

Visit the Persistent World of Nymri

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 Prefab Areas


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