2 tokenize questions

  1. I notice that tokenize2 allows you to tokenize by + additional delimiters, but what if I want to tokenize on “,” only and leave the spaces alone? Is this possible?

  2. If I have a string that I want to tokenize, and then I want to tokenize on one of the strings therein, how can one do this?

Ok, (2) needs an example.
I want to take the string “bob:32:wizard|big caulk:16:warrior” and do something like:

array = split(theString,|)
for (i = 0 ; i < arrayLen(array) ; i++) {
  array2 = split(array[i],:)
  for (j = 0 ; j < arrayLen(array2) ; j++) {
    // do stuff with array2[j] which is bob,32, and then wizard on the first iteration of i
    // on the second iteration of i, array2[j] is big caulk, 16, and then warrior
    // notice that "big caulk" stays together

Basically what’s the easiest way to do what java’s, c#'s, c’s, python’s, 's String.split() method does?

For the first question I would suggest you make a custom tokenize method. Since im such a no lifer and it wasnt hard this was my idea that works.

// NPC made by tricxta
if (playerenters){
  setstring this.delims,* . ( );
  setstring this.text,hi* this is no (black magic);
  for (i=0;i<strlen(#s(this.text))+1;i++){
    if (strcontains(#s(this.delims),#e(i,1,#s(this.text)))){
      setstring t#v(tokencount),#e(wordstart,i-wordstart,#s(this.text));

It would be cool if paramters worked for methods because it would be neat just doing tokenize3(#s(this.test));
As for your second question I have no idea what your asking because im exhausted from uni and I cant really be bothered soz

I figured it was possible to use indexOf and strcontains to write a custom tokenize method. I was just wondering if there was some function that didn’t make it into commands.rtf or something since it seems like such a fundamentally handy function. ~sigh~.

I should start putting together a library of useful functions and just use join to get the same boilerplate utility functions in all my scripts.

Does anybody know if the 12k char limit (or whatever it is) applies to scripts that use join?

i.e. could I get away with having a script that just does “if (created) join myFiveHundredMbNPC;”? Haha, that would be interesting.

I beleive the cap limit for a script is 13kb. This is in both a text file or an npc in the editor. Also with the join command I do this:
level script:

join test;

text file called test:

if (created){
  message sup!;

Hope this clears up some stuff for you.

Join doesn’t circumvent the limit.

Nuts. Guess I’ll still have to watch my character usage in my .txt npcs as well.