Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-03-2014, 05:22 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
For what its worth, params start at 0

Your npc script:
params[0] = buymenu1
params[1] = 1000
params[2] = nameyouhad?

Also, you can do:
onActionClientside (cmd, price, itemname)
and reference the parameters passed from serverside that way.

Ex: echo(price);
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #2  
Old 02-05-2014, 06:22 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Quote:
Originally Posted by Torankusu View Post
For what its worth, params start at 0

Your npc script:
params[0] = buymenu1
params[1] = 1000
params[2] = nameyouhad?

Also, you can do:
onActionClientside (cmd, price, itemname)
and reference the parameters passed from serverside that way.

Ex: echo(price);
Ahh, thanks for the reply anyways .

Would anyone be able to explain tokenizing to me/link me to anything on it please?
__________________
Reply With Quote
  #3  
Old 02-05-2014, 11:45 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by iDigzy View Post
Ahh, thanks for the reply anyways .

Would anyone be able to explain tokenizing to me/link me to anything on it please?
obj.tokenize([delimiters]) - splits the string into an array wherever the delimiters occur

Example:
Player chats: "This is an example"

PHP Code:
player.chat.tokenize(" "); //uses spaces as separator 
Can access tokens like this:
tokenscount (will yield 4)
tokens[0] will reference the first token (the word "this").
Similarly,
tokens[2] will reference the word "an".
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
Reply With Quote
  #4  
Old 02-05-2014, 10:47 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by Torankusu View Post
obj.tokenize([delimiters]) - splits the string into an array wherever the delimiters occur

Example:
Player chats: "This is an example"

PHP Code:
player.chat.tokenize(" "); //uses spaces as separator 
Can access tokens like this:
tokenscount (will yield 4)
tokens[0] will reference the first token (the word "this").
Similarly,
tokens[2] will reference the word "an".
ps: if its only for spaces, you could also just do player.chat.tokenize()
__________________
MEEP!
Reply With Quote
  #5  
Old 02-05-2014, 11:51 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Quote:
Originally Posted by Torankusu View Post
obj.tokenize([delimiters]) - splits the string into an array wherever the delimiters occur

Example:
Player chats: "This is an example"

PHP Code:
player.chat.tokenize(" "); //uses spaces as separator 
Can access tokens like this:
tokenscount (will yield 4)
tokens[0] will reference the first token (the word "this").
Similarly,
tokens[2] will reference the word "an".
Thanks , would you use tokenizeing as well when doing such scripts as
PHP Code:
if (player.chat.starts("text")){ 
player.chat.substring;

?
Also, for the delimiters, you would basically be able to put for example a word such as "idigzy" and wherever that word occurs it splits it :o?
__________________
Reply With Quote
  #6  
Old 02-06-2014, 12:31 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Quote:
Originally Posted by iDigzy View Post
Thanks , would you use tokenizeing as well when doing such scripts as
PHP Code:
if (player.chat.starts("text")){ 
player.chat.substring;

Your example isn't a proper use of substring ( string.substring(index[,length]) ) , but, essentially, yes, you could tokenize the player's chat if a condition is met. I'll let someone else fill you in on substring as I know how it works (sometimes), but am not familiar enough to verse you on its uses...sorry...


random tailor example for tokenize [better ways to do this...example for simplicity sake..]:
PHP Code:
if (player.chat.starts("/set ")){ //player says "/set shoes"
  
player.chat.tokenize(); //as previously mentioned, SPACES become separators
  
if (tokens[1] == "shoes"){
    
player.colors[2] = tokens[2];
    
//OR...
    //player.colors[2] = player.chat.substring(10,-1); // not 100% sure on this??
  
}

Quote:
Also, for the delimiters, you would basically be able to put for example a word such as "idigzy" and wherever that word occurs it splits it :o?
yeah, you get the concept....
some common delimiters: are , (commas), spaces . (periods) , and so on...

there is a tokenize2 but I didn't want to include it.
You can scripthelp it.

Is there anything you are trying to do in specific, there might be a better approach?
__________________
Quote:
Originally posted by Spark910
Think befreo you type.
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 07:17 AM.


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