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  



NWN SCRIPTS

- Jump to comments -
Title  String Tokenizer - Advanced Data Storage
Author  Knat
Submitted / Updated  09-16-2002 / 11-22-2006
Category  Scripting routines
Expansions  NWN-1.25
Format  Code Only
Type  Type - Arrays
Includes  BioWare Standard
Description
String Tokenizer - Advanced Data Storage Updated to V1.2 Added new function for better memory control and optimized cache Updated to V1.1. added two new functions and did some general improvements. this version needs v1.25+ to work... just re-download it and import the .erf it's 100% backward compatible. This small library of functions helps you with all kind of data management and data consolidation. Be it dynamic arrays, multidimensional arrays or stuff like linked lists.. it also helps you to establish a standardized way of data manipulation throughout all your scripts. with the use of a simple caching algorithm, data access is nearly as fast as a normal GetLocal.. function call. Tokenizer functions are common in most modern compilers, why not using them with the aurora engine ? It's key/value based data access is ideally suited for such a system. the zip file contains a small tutorial.. search the bioware forums for further discussion.

Files

NameTypeSizeDownloads
tokenizer12.ziptokenizer12.zip
Submitted: 09-16-2002 / Last Updated: 11-27-2003
zip5.24Kb1478
--
SCORE OUT OF 10
9.85
7 votes
View Stats
Cast Your Vote!

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 (20):

Posted by dunahan at 2011-09-11 05:49:31    Voted 10.00 on 09/11/11
Wonderful system! Created a treasure-table which can be altered online ;) and sooo fast!
Thx for sharing!
_________________________
Link

Isladora, an island in the Sea of Swords

Posted by Knat at 2005-12-23 10:18:00    
test..

Posted by jen at 2005-03-23 08:24:58    Voted 9.25 on 03/23/05

Posted by Rabidness at 2004-07-04 21:57:50    Voted 10.00 on 07/04/04
Awesome, very usefull script!

Posted by Gareth C ( ..xxx.xxx ) at 2004-04-05 03:43:00    
This is a really useful script. I couldn�t believe that the scripting set came with no kind of array data class, but these tokenised strings fill the gap. It�s clever in a �why didn�t I think of that� way.

By the way, there is a small problem. If you do this:




//Create a new tokenized string, but in this case it has only 1 token
string MyArray1="foo1~foo2~foo3";


//create a new empty array
string MyArray2="";

//Add data to it
// Source Sink
MyArray2=AddTokenToString(MyArray1,MyArray2,"|");

// MyArray1="foo1~foo2~foo3" , Delimiter="~" , 3 tokens
// MyArray2="foo1~foo2~foo3" , Delimiter="|" , 1 token

string Output1=GetTokenFromString(1,MyArray2,"|");
//Output="foo1~foo2~foo3"

string Output2=GetTokenFromString(1,Output1,"~");
//Output2="foo1~foo2~foo3", expected:"foo1"

PrintString("Output1="+Output1);
PrintString("Output2="+Output2);



The problem is to do with the cache. Fortunatly it's easy to solve:



void BuildCache(string sTargetString, string sDelimiter = "|")
{
string s = sTargetString;
if(s == "") return;

int c = 0;
int pos = 0;
string sToken;

while(pos != -1)
{
c++;
pos = FindSubString(s,sDelimiter);
if(pos == -1) // last token ?
{
SetLocalInt(oCache,"#C#"+sDelimiter+sTargetString+s, c);
SetLocalString(oCache,"#C#"+sDelimiter+sTargetString+IntToString(c),s);
SetLocalInt(oCache,"#C#"+sDelimiter+sTargetString,c);
return;
}
sToken = GetStringLeft(s,pos);
SetLocalInt(oCache,"#C#"+sDelimiter+sTargetString+sToken, c);
SetLocalString(oCache,"#C#"+sDelimiter+sTargetString+IntToString(c),sToken);
s = GetStringRight(s,GetStringLength(s)-(pos+1)); // cut off leading token+delimiter
}
}



As you can see I've added the sDelimiter to each cashed string. You need to update all the other functions accordingly, especially DeleteStringFromTokenCache(string sTargetString) which is broken. The only way I can think of to fix it is to get the user to provide the Delimiter.

I would have posted this on the neverwinter nights scripting bord, but I couldn't find the thread.

Posted by Gareth C ( ..xxx.xxx ) at 2004-04-05 03:42:00    
This is a really useful script. I couldn�t believe that the scripting set came with no kind of array data class, but these tokenised strings fill the gap. It�s clever in a �why didn�t I think of that� way.

By the way, there is a small problem. If you do this:




//Create a new tokenized string, but in this case it has only 1 token
string MyArray1="foo1~foo2~foo3";


//create a new empty array
string MyArray2="";

//Add data to it
// Source Sink
MyArray2=AddTokenToString(MyArray1,MyArray2,"|");

// MyArray1="foo1~foo2~foo3" , Delimiter="~" , 3 tokens
// MyArray2="foo1~foo2~foo3" , Delimiter="|" , 1 token

string Output1=GetTokenFromString(1,MyArray2,"|");
//Output="foo1~foo2~foo3"

string Output2=GetTokenFromString(1,Output1,"~");
//Output2="foo1~foo2~foo3", expected:"foo1"

PrintString("Output1="+Output1);
PrintString("Output2="+Output2);



The problem is to do with the cache. Fortunatly it's easy to solve:



void BuildCache(string sTargetString, string sDelimiter = "|")
{
string s = sTargetString;
if(s == "") return;

int c = 0;
int pos = 0;
string sToken;

while(pos != -1)
{
c++;
pos = FindSubString(s,sDelimiter);
if(pos == -1) // last token ?
{
SetLocalInt(oCache,"#C#"+sDelimiter+sTargetString+s, c);
SetLocalString(oCache,"#C#"+sDelimiter+sTargetString+IntToString(c),s);
SetLocalInt(oCache,"#C#"+sDelimiter+sTargetString,c);
return;
}
sToken = GetStringLeft(s,pos);
SetLocalInt(oCache,"#C#"+sDelimiter+sTargetString+sToken, c);
SetLocalString(oCache,"#C#"+sDelimiter+sTargetString+IntToString(c),sToken);
s = GetStringRight(s,GetStringLength(s)-(pos+1)); // cut off leading token+delimiter
}
}



As you can see I've added the sDelimiter to each cashed string. You need to update all the other functions accordingly, especially DeleteStringFromTokenCache(string sTargetString) which is broken. The only way I can think of to fix it is to get the user to provide the Delimiter.

I would have posted this on the neverwinter nights scripting bord, but I couldn't find the thread.

Posted by Balkur at 2004-03-29 11:19:08    Voted 10.00 on 03/29/04
This has to be one of the most useful little scripts out there. I'm using it *everywhere* in my code.

Posted by MorganQuickthrust at 2004-03-15 16:06:27    Voted 10.00 on 03/15/04

Posted by Old_Scores_Transfered at 2004-02-20 10:29:15    Voted 9.00 on 02/20/04
This is a compilation of the old system into a single score. There were 9 that made this score of 9.00 then rounded to 9.

Posted by Knat ( ..xxx.xxx ) at 2003-11-27 05:30:00    
updated the recond... should be available again, soon...

Posted by hermyt ( ..xxx.xxx ) at 2003-11-21 19:13:00    
damnation the server is down....

Posted by Cyberqat ( ..xxx.xxx ) at 2003-03-11 22:07:00    
This is ALMOSt perfect for me.

It would be perfect if it had a function to insert a token
at a given token position as I wish to keep an ordered
token list.

I looekd at your code with teh though to add it but at the
moment Im too brain dead to udnerstand your caching scheme.

Could you add this? Or at least give my a pointer or two on
how to add it in?

Thanks

CQ




Posted by Wolkenfels ( ..xxx.xxx ) at 2003-03-04 07:13:00    
Sounds very helpful - and the text explains it quite well.
Unfortunatly its build with a patch1.28-version. Our Server
ist still 1.27 so i have to wait for the final german 1.28
patch to use it. :-/

Posted by Timdalos ( ..xxx.xxx ) at 2003-03-02 21:48:00    
YAY! This is WONDERFUL... an update to my absolutely all
time favorite most useful, absolutely can't live without it
script pack... thanks for a GREAT bit of work... truely,
without this set of functions, I'd be completely unable to
script at all in NWN, the basic data handling is so
primitive. And my skill levels are so dependent on and used
to working with much higher level languages. ;-)



Posted by DirtyBerk ( ..xxx.xxx ) at 2003-02-06 11:46:00    
Man, I wish I had this before I did my random encounter
system. Now I'll have to update it with much better and
easier-to-update options!

Great work!

Posted by Narok ( ..xxx.xxx ) at 2003-01-03 21:18:00    

Boy, I wish I knew how I could find this useful.

Not that it's not useful, I just don't know what the hell
you're talking about. Because I can't code or script.

Posted by bmm0321 ( ..xxx.xxx ) at 2002-11-05 17:26:00    
Great work ... since my C skills are rusty, this saved me
a ton of work. Thanks for the effort, it is greatly
appreciated.

Posted by Knat ( ..xxx.xxx ) at 2002-09-17 05:28:00    
it does not interfere with any other script.

and it does not have anything to do with item-tokens. it's
just a collection of generic and fast data manipulation
functions. (String Tokenizer)

search for "Advanced Data" in the bioware forums, you will
find a thread answering all possible questions.

Knat

Posted by Arckon ( ..xxx.xxx ) at 2002-09-17 04:03:00    
Looks great, Knat, but is it compatible with the Hard Core
Rules System, the Ambrosia Trade System or The Persistent
World Universal Mind?

I think HCR and ATS use tokens for PC data also, will yours
over-write any of their tokens?

Posted by sewyrn ( ..xxx.xxx ) at 2002-09-17 03:23:00    
Sounds interesting. I'm definitely going to have to check
this out.

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

 
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