Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   using tokenscount (https://forums.graalonline.com/forums/showthread.php?t=134259963)

Jiroxys7 07-27-2010 04:27 AM

using tokenscount
 
okay, so lets say i've done temp.test = clientr.equips_weapon.tokenize(",");
how do i get the number of tokens produced with tokenscount? It seems to be returning 0 whatever I do.

Also, do i need to even do temp.test = var.tokenize(","); or can i simply leave it as var.tokenize(","); and proceed to checking the number of tokens produced with tokenscount?

And also, would I be able to somehow use tokenscount easily with an array?
Example, Lets say I have:
PHP Code:

temp.array = {
  
var1.tokenize(","),
  
var2.tokenize(","),
  
//etc
} 

or, assuming it would work:
PHP Code:

temp.array.tokenize(",") = {
  
var1,
  
var2,
  
//etc
} 

would there be a way to grab the tokenscount of var1 and var2 without being required to do something like:
PHP Code:

temp.array[0].tokenize(",");
var.
a = tokenscount;
temp.array[1].tokenize(",");
var.
b = tokenscount;
//etc 

or something?

salesman 07-27-2010 04:36 AM

tokenize() returns an array of tokens, so
PHP Code:

temp.tokens = temp.str.tokenize(",");
temp.count = temp.tokens.size(); 

will give you the number of tokens.


You can use tokenize(delim) on any string where delim specifies the delimiter (or what you want to use to separate the string).

cbk1994 07-27-2010 04:58 AM

If you're using an array, you don't need to tokenize it by a comma.

PHP Code:

temp.array = clientr.equip_weapons; 

In addition, tokenscount is GS1. The proper GS2 is:
PHP Code:

temp.tokens = str.tokenize(delim);
temp.size = tokens.size(); 



All times are GMT +2. The time now is 01:14 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.