Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-06-2001, 03:07 AM
XilosTinsu XilosTinsu is offline
Registered User
Join Date: Jun 2001
Posts: 130
XilosTinsu is on a distinguished road
Send a message via AIM to XilosTinsu Send a message via Yahoo to XilosTinsu
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.
Reply With Quote
  #2  
Old 06-06-2001, 04:32 AM
Brandon_Bravo Brandon_Bravo is offline
Registered User
Join Date: Jun 2001
Location: Kalamazoo, Michigan USA
Posts: 206
Brandon_Bravo is on a distinguished road
Send a message via ICQ to Brandon_Bravo Send a message via AIM to Brandon_Bravo Send a message via MSN to Brandon_Bravo Send a message via Yahoo to Brandon_Bravo
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.



__________________
Brandon M.

Last edited by Brandon_Bravo; 06-06-2001 at 06:03 AM..
Reply With Quote
  #3  
Old 06-06-2001, 07:25 AM
Bravo_NPC-Admin1 Bravo_NPC-Admin1 is offline
Registered User
Join Date: May 2001
Location: Olympia, Washington USA
Posts: 25
Bravo_NPC-Admin1 is on a distinguished road
Send a message via AIM to Bravo_NPC-Admin1 Send a message via Yahoo to Bravo_NPC-Admin1
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.
__________________
-Boco
Reply With Quote
  #4  
Old 06-06-2001, 08:18 AM
XilosTinsu XilosTinsu is offline
Registered User
Join Date: Jun 2001
Posts: 130
XilosTinsu is on a distinguished road
Send a message via AIM to XilosTinsu Send a message via Yahoo to XilosTinsu
Well thanx alot you've helped out a bunch.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:24 AM.


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