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 07-30-2017, 09:20 AM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
damn chris out of nowhere
__________________
Reply With Quote
  #2  
Old 07-30-2017, 11:19 AM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,746
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Quote:
Originally Posted by cbk1994 View Post
Post
I see how the class works, but I don't understand what is happening in your post so bear with me.
HTML Code:
function deposit(temp.amountToDeposit) { 
} 
I understand that "deposit" is a custom function. Is it being called by the triggerserver command? And how is "temp.amountToDeposit" assigned a value? I assume triggerserver is passing the value of the chat, similar to how tokenize worked in GS1, to the function?

Does including the variable name in the function act similarly to assigning the variable value? Like "temp.amountToDeposit = player.chat.substring(9).trim());" ?

HTML Code:
function onActionServerSide(temp.cmd, temp.amount) { 
  if (temp.cmd == "deposit") { 
    this.deposit(temp.amount); 
  } 
} 
Again, how does "temp.cmd" and "temp.amount" get assigned values? In the deposit function I can sort of understand that triggerserver calls the function. Does "onActionServerSide" also catch the values that are being sent? Maybe it would help if you posted the format of how triggerserver is to be used.

Quote:
Originally Posted by fowlplay4 View Post
Post
Thanks, these were things I didn't really consider. So mostly join is used for convenience?
__________________
Save Classic!

Last edited by maximus_asinus; 07-30-2017 at 12:20 PM..
Reply With Quote
  #3  
Old 07-30-2017, 05:43 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 maximus_asinus View Post
I understand that "deposit" is a custom function. Is it being called by the triggerserver command? And how is "temp.amountToDeposit" assigned a value? I assume triggerserver is passing the value of the chat, similar to how tokenize worked in GS1, to the function?
It's called by the serverside half of the ATM weapon:

PHP Code:
    this.deposit(temp.amount); 
Because the weapon has joined functions_bank, the deposit function is available inside the weapon without copy-pasting it. It gets called at the "this.deposit(temp.amount)" line, after the trigger is received on serverside from the client.

Quote:
Does including the variable name in the function act similarly to assigning the variable value? Like "temp.amountToDeposit = player.chat.substring(9).trim());" ?

Again, how does "temp.cmd" and "temp.amount" get assigned values? In the deposit function I can sort of understand that triggerserver calls the function. Does "onActionServerSide" also catch the values that are being sent? Maybe it would help if you posted the format of how triggerserver is to be used.
When you use a trigger from clientside to serverside like this, the arguments passed to the function here (after "gui" and the weapon name):

PHP Code:
triggerServer("gui"this.name"deposit"player.chat.substring(9).trim()); 
...end up as the arguments to onActionServerSide function on serverside. So temp.cmd ends up as "deposit", tmp.amount ends up with the value of "player.chat.substring(9).trim()".

You're right that substring is similar to tokenize, it could alternatively be written:


PHP Code:
triggerServer("gui"this.name"deposit"player.chat.tokenize()[1]); 
The difference is that tokenize breaks up the line of chat into words, whereas substring takes everything after the ninth character. Tokenize is probably actually a better choice here anyway.

So the flow in this script is [play chats clientside] => [trigger is sent from clientside to serverside] => [trigger arrives in onActionServerSide block] => [onActionServerSide block calls this.deposit].

Triggers are a quirky feature of GScript (and I probably should've picked an example that didn't use them -- sorry), there are some good explanations at http://www.graal.net/index.php/Creat.../Helpful_Posts and in particular this post: http://forums.graalonline.com/forums...84&postcount=6

Quote:
Originally Posted by Crono View Post
damn chris out of nowhere
<3
__________________
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 10:07 AM.


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