Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-17-2002, 02:08 AM
Poogle Poogle is offline
Registered User
Poogle's Avatar
Join Date: Jun 2001
Posts: 2,471
Poogle is on a distinguished road
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).;
}
}

Reply With Quote
  #2  
Old 06-17-2002, 02:18 AM
GrowlZ1010 GrowlZ1010 is offline
defunct
Join Date: May 2002
Posts: 187
GrowlZ1010 is on a distinguished road
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?
Reply With Quote
  #3  
Old 06-17-2002, 04:35 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
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?
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #4  
Old 06-17-2002, 04:39 AM
Poogle Poogle is offline
Registered User
Poogle's Avatar
Join Date: Jun 2001
Posts: 2,471
Poogle is on a distinguished road
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
Reply With Quote
  #5  
Old 06-17-2002, 05:04 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
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)
Reply With Quote
  #6  
Old 06-17-2002, 11:53 AM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
Regular tokenize does not accept parameters...

tokenize2 string,params
Reply With Quote
  #7  
Old 06-17-2002, 08:14 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
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.....
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #8  
Old 06-17-2002, 08:37 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to 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
__________________
Who has time for life these days?
Reply With Quote
  #9  
Old 06-17-2002, 08:42 PM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
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...
Reply With Quote
  #10  
Old 06-17-2002, 08:44 PM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
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.
__________________

subliminal message: 1+1=3
Reply With Quote
  #11  
Old 06-18-2002, 10:37 AM
Shorty2Dope Shorty2Dope is offline
Psychopathic
Shorty2Dope's Avatar
Join Date: Oct 2001
Location: Insane Asylum
Posts: 3,290
Shorty2Dope is on a distinguished road
Send a message via AIM to Shorty2Dope Send a message via Yahoo to Shorty2Dope
Whats the #s() for/do?
__________________
blah
Reply With Quote
  #12  
Old 06-18-2002, 10:48 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
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.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #13  
Old 06-18-2002, 03:57 PM
Dragona2002 Dragona2002 is offline
Registered User
Join Date: May 2002
Location: The Netherlands
Posts: 105
Dragona2002 is on a distinguished road
Send a message via AIM to Dragona2002 Send a message via Yahoo to Dragona2002
Talking ........

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
__________________

Quote:
The Dark Nemesis begins.......
Reply With Quote
  #14  
Old 06-18-2002, 06:03 PM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
anything you do with strings (message code) you will always use #s()....
Reply With Quote
  #15  
Old 06-18-2002, 08:02 PM
screen_name screen_name is offline
is watching you
Join Date: Mar 2002
Location: The 3rd Dimension
Posts: 2,160
screen_name is on a distinguished road
Send a message via AIM to screen_name Send a message via MSN to screen_name
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;
}

__________________
[signature]insert here[/signature]
Reply With Quote
Reply


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 12:34 PM.


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