Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #46  
Old 02-03-2014, 04:22 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,057
Torankusu has a spectacular aura aboutTorankusu has a spectacular aura about
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
  #47  
Old 02-05-2014, 05: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
  #48  
Old 02-05-2014, 10:45 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,057
Torankusu has a spectacular aura aboutTorankusu has a spectacular aura about
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"

Graal Script 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
  #49  
Old 02-05-2014, 09: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"

Graal Script 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
  #50  
Old 02-05-2014, 10: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"

Graal Script 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
Graal Script 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
  #51  
Old 02-05-2014, 11:31 PM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,057
Torankusu has a spectacular aura aboutTorankusu has a spectacular aura about
Quote:
Originally Posted by iDigzy View Post
Thanks , would you use tokenizeing as well when doing such scripts as
Graal Script 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..]:
Graal Script 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
  #52  
Old 02-06-2014, 12:37 AM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
@Torankusu Thanks for all the help on that . I'm not really trying to do anything in particular at the moment, I just thought I'd play around with it since I may use it in the future.
__________________
Reply With Quote
  #53  
Old 02-06-2014, 02:16 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Send a message via Skype™ to sssssssssss
Graal Script Code:
str.substring(start[,length]) - extracts a substring out of str 
the second parameter is how long you want to grab for the substring. -1 for the length will go to the end of the string.

Also
Graal Script Code:
function ChatBar.onAction() 
is the same as
Graal Script Code:
function onPlayerChats() 
From what I understand it's recommended to use ChatBar. I've even had issues with playerchats here and there, but not with chatbar. ChatBar is the Gui default where you type in the text.

and
Graal Script Code:
ChatBar.text 
is the same as
Graal Script Code:
player.chat 
when using the ChatBar function instead.

so:
Graal Script Code:
function ChatBar.onAction() {
  if (
ChatBar.substring(04) == "/set") { //honestly i cant remember if it starts at 0 or 1, I believe its 0. If not, you'd do 1, 4
    
temp.tokens ChatBar.text.tokenize(); //as previously mentioned, SPACES become separators
  
if (tokens[1] == "shoes"){
    
player.colors[2] = tokens[2];
  }
}
// i believe you could dynamically set it with substrings, but since it's already in tokens, it's better to just use the tokens. 
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #54  
Old 02-07-2014, 06:23 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
@sssssssssss thanks for the response
__________________
Reply With Quote
  #55  
Old 02-07-2014, 11:34 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Send a message via Skype™ to sssssssssss
I saw an error in my code. :x sry

Graal Script Code:
function ChatBar.onAction() {
  if (
ChatBar.text.substring(04) == "/set") { //honestly i cant remember if it starts at 0 or 1, I believe its 0. If not, you'd do 1, 4
    
temp.tokens ChatBar.text.tokenize(); //as previously mentioned, SPACES become separators
  
if (tokens[1] == "shoes"){
    
player.colors[2] = tokens[2];
  }
}
// i believe you could dynamically set it with substrings, but since it's already in tokens, it's better to just use the tokens. 
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #56  
Old 02-09-2014, 03:12 PM
iDigzy iDigzy is offline
Registered User
Join Date: Apr 2013
Posts: 44
iDigzy is on a distinguished road
Would anyone be able to link me to some guides on databases/some good examples ?
__________________
Reply With Quote
  #57  
Old 02-09-2014, 05:48 PM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Quote:
Originally Posted by iDigzy View Post
Would anyone be able to link me to some guides on databases/some good examples ?
The Graal wiki has a good page on the use of SQLite in GScript.

http://wiki.graal.net/index.php/Crea...t/Using_SQLite
Reply With Quote
  #58  
Old 02-09-2014, 08:28 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by cyan3 View Post
The Graal wiki has a good page on the use of SQLite in GScript.

http://wiki.graal.net/index.php/Crea...t/Using_SQLite
I wouldn't really call it a good page. A lot of the explanation is not very clear and I didn't have a very good understanding of SQLite when I wrote it.

My advice would probably be to learn SQL/SQLite outside of Graal first. Using it in Graal will then be pretty easy.
__________________
Reply With Quote
  #59  
Old 02-10-2014, 09:11 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 sssssssssss View Post
I saw an error in my code. :x sry

Graal Script Code:
function ChatBar.onAction() {
  if (
ChatBar.text.substring(04) == "/set") { //honestly i cant remember if it starts at 0 or 1, I believe its 0. If not, you'd do 1, 4
    
temp.tokens ChatBar.text.tokenize(); //as previously mentioned, SPACES become separators
  
if (tokens[1] == "shoes"){
    
player.colors[2] = tokens[2];
  }
}
// i believe you could dynamically set it with substrings, but since it's already in tokens, it's better to just use the tokens. 
now if there isnt some kind of error then ill restart scripting and learn it all from the beginning
__________________
MEEP!
Reply With Quote
  #60  
Old 02-11-2014, 12:49 PM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Send a message via Skype™ to sssssssssss
:x
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


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


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.