Graal Forums

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

XilosTinsu 06-06-2001 03:07 AM

Tokenize
 
OK I'm a fairly decent scripter but not super good at it, but I'm trying to learn and I have no idea what tokenize does or is used for, can someone give me a simple example of what it does and like a basic NPC that uses it, ANYTHING.

Brandon_Bravo 06-06-2001 04:32 AM

Re: Tokenize
 
Certainly.

Tokenizing a string separates it into units called tokens.

For example:

if a playerchats and says:

warpto 30 30 onlinestartlocal.graal

#t(1) would be the first 30
#t(2) would be the second 30
#t(3) would be onlinestartlocal.graal

[ Tokens are called by using the form #t(ID) ]

An example of this is:
NPC Code:
if (playerchats) {
if (startswith(warpto,#c)) {
levelwarp();
}
}
function levelwarp() {
tokenize #c;
setstring this.level,#t(1);
setstring this.x,#t(2);
setstring this.y,#t(3);
setlevel2 #s(this.level),#s(this.x),#s(this.y);
}



That is a small example of Tokenizing.




Bravo_NPC-Admin1 06-06-2001 07:25 AM

Also...
 
Tokenize breaks up a string into sections, or tokens. Take this string for example:
Tokenize this string for me

If you call tokenize with this string, it would create:
#t(0)=tokenize
#t(1)=this
#t(2)=string
#t(3)=for
#t(4)=me

There are some exceptions:
Tokenize "this string" for me

When tokenized:
#t(0)=tokenize
#t(1)=this string
#t(2)=for
#t(3)=me

You can see that everything inbetween parenthesis are taken as 1 token. There you go.

XilosTinsu 06-06-2001 08:18 AM

Well thanx alot you've helped out a bunch.


All times are GMT +2. The time now is 07:43 PM.

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