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.
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,"|");
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,"|");
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
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.