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=31741)

Poogle 06-17-2002 02:08 AM

Tokenize
 
What is wrong with this? This is my first time with tokenize and I am needing help
NPC Code:
if (timeout) {
//#CLIENTSIDE
if (playerenters) {
setcoloreffect #t(this.red),#t(this.green),#t(this.blue),#t(this. alpha);
drawaslight;
}
if (strcontains(#c ,setred )) {
tokenize #c,red;
setplayerprop #c,Red was set to #t(red).;
}
}


GrowlZ1010 06-17-2002 02:18 AM

The command tokenize doesn't accept arguments. Put bluntly, no commas. Also, I'd use startswith instead of strcontains: it means that saying "Oh, yeah, you just say setred to do that" won't trigger the script. What exactly are you trying to do?

adam 06-17-2002 04:35 AM

Re: Tokenize
 
Quote:

Originally posted by Poogle
What is wrong with this? This is my first time with tokenize and I am needing help
NPC Code:
if (timeout) {
//#CLIENTSIDE
if (playerenters) {
setcoloreffect #t(this.red),#t(this.green),#t(this.blue),#t(this. alpha);
drawaslight;
}
if (strcontains(#c ,setred )) {
tokenize #c,red;
setplayerprop #c,Red was set to #t(red).;
}
}


im guessing this isn't the whole script?

Poogle 06-17-2002 04:39 AM

Quote:

Originally posted by GrowlZ1010
The command tokenize doesn't accept arguments. Put bluntly, no commas. Also, I'd use startswith instead of strcontains: it means that saying "Oh, yeah, you just say setred to do that" won't trigger the script. What exactly are you trying to do?
Say setred to change the color of the light
NPC Code:
// NPC made from ZicklePop Productions
if (created) {
setimg light2.png;
dontblock;
timeout = 0.01;
}
if (timeout) {
//#CLIENTSIDE
if (playerenters) {
setcoloreffect #t(this.red),#t(this.green),#t(this.blue),#t(this. alpha);
drawaslight;
}
if (startswith(#c ,setred )) {
tokenize #c,red;
setplayerprop #c,Red was set to #t(red).;
}
}


Updated

Python523 06-17-2002 05:04 AM

Quote:

Originally posted by Poogle
Say setred to change the color of the light
NPC Code:
// NPC made from ZicklePop Productions
if (created) {
setimg light2.png;
dontblock;
timeout = 0.01;
}
if (timeout) {
//#CLIENTSIDE
if (playerenters) {
setcoloreffect #t(this.red),#t(this.green),#t(this.blue),#t(this. alpha);
drawaslight;
}
if (startswith(#c ,setred )) {
tokenize #c,red;
setplayerprop #c,Red was set to #t(red).;
}
}


Updated

tokenize #c;
setred = #t(0)

nyghtGT 06-17-2002 11:53 AM

Regular tokenize does not accept parameters...

tokenize2 string,params

adam 06-17-2002 08:14 PM

if (playerchats&&startswith(setred,#c)){
tokenize #c;
this.red = strtofloat(#t(1));
}

NPC Code:


setstring list,Hello how are you today;
tokenize #s(list); // don't forget the #s() here;

// #t(0) will = Hello , #t(1) will = how , and so on.

tokenize Hello how are you today; // don't need the #s() doing it this way
// #t(0) will = Hello lik ebefore

setstring list, ab.c.defg.hi.jklmnop;
tokenize2 . , #s(list); // don'tforget teh #s() here

// #t(0) will = ab ; #t(1) will = c ; #t(2) will = defg ;

tokenize2 #, hello#how#are#you; // don't need #s() here;

// #t(0) will = hello ; #t(1) will = how ; #t(2) will = are ; and so on



That should be enough examples.....

Projectshifter 06-17-2002 08:37 PM

LOL, I don't use tokenize much, but wouldn't it just be easier to use variables?
if (playerchats&&startswith(#c,setred)) this.color=red;
if (this.color==red) ACTION; or perhaps use numbers instead of words?
---Shifter

nyghtGT 06-17-2002 08:42 PM

Quote:

Originally posted by Projectshifter
LOL, I don't use tokenize much, but wouldn't it just be easier to use variables?
if (playerchats&&startswith(#c,setred)) this.color=red;
if (this.color==red) ACTION; or perhaps use numbers instead of words?
---Shifter

this.color=red will not work.

you can not save word values to variables...

Falcor 06-17-2002 08:44 PM

It looks like you have a grasp of it, but it looks like something is wrong with your description. Tokenize itself will split a string into parts seperated by spaces and commas.

setstring string,hello world;
tokenize #s(string);
and
tokenize hello world;

will both give you 2 tokens

#t(0) = hello
#t(1) = world

tokenize2 will add extra delimeters (delimeters are the letters or characters that the tokens will be split, this is ADDED to the 2 default ones: spaces and commas)

so

tokenize2 -,hello-world,foo=bar;
or
setstring string,hello-world,foo=bar;
tokenize2 -,#s(string);

will both give you 3 tokens.

#t(0): hello (which uses your extra delemiter "-" )
#t(1): world (which is sperated by the default comma delimeter)
#t(2): foo=bar (which is the last token)

In response to adams information that you do not need a #s() for tokenize2. That is a confusing statment. Any valid string parameter in the syntax of any script in graal is viable to use the #s() message code.

Shorty2Dope 06-18-2002 10:37 AM

Whats the #s() for/do?

adam 06-18-2002 10:48 AM

Quote:

Originally posted by Falcor

In response to adams information that you do not need a #s() for tokenize2. That is a confusing statment. Any valid string parameter in the syntax of any script in graal is viable to use the #s() message code.

??
Sorry. I don't get your meaning.

Nice of you to offer a second explanation from a different point of view I guess..... I thought mine was a fine explanation though.

Dragona2002 06-18-2002 03:57 PM

........
 
gees....

if you use #t (0) you have to use #t (1) in it 2 XD
else it wont reconize the string of the value of the blah blah blah

i like to talk this way :D

nyghtGT 06-18-2002 06:03 PM

anything you do with strings (message code) you will always use #s()....

screen_name 06-18-2002 08:02 PM

NPC Code:

if (created) {
setimg light2.png;
dontblock;
timeout = 0.1;
}

if (timeout) {
//#CLIENTSIDE
if (startswith(setred,#c)) {
tokenize #c;
if (tokenscount==5 && strequals(#t(0),setred)) {
setplayerprop #c,Red was set to #t(1).;
SetRed();
} elsif (tokenscount!=5) {
say2 Incorrect syntax...;
}
}
timeout=.1;
}

function SetRed() {
setcoloreffect #t(1),#t(2),#t(3),#t(4);
drawaslight;
}



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

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