Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-17-2002, 11:29 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
function question

Does stuff like this work?
NPC Code:

NPC Code:

operator(1,7);

function operator(a,b) {
message a;
sleep 1.75;
message b;
}




I've tried it and nothing happens but if its messed up somewhere please correct me.
Reply With Quote
  #2  
Old 05-18-2002, 12:24 AM
GrowlZ1010 GrowlZ1010 is offline
defunct
Join Date: May 2002
Posts: 187
GrowlZ1010 is on a distinguished road
It won't work, no. Graal has no support for function parameters at the moment.
Reply With Quote
  #3  
Old 05-18-2002, 09:04 AM
Bhala Bhala is offline
Disgruntled Monkey
Bhala's Avatar
Join Date: Mar 2001
Posts: 779
Bhala is on a distinguished road
All a function is in graal is code replacement.... like saying

if(true){
dothis();
}
function dothis(){
message done!;
}


is the same as

if(true){
message done!;
}
Reply With Quote
  #4  
Old 05-18-2002, 10:43 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
Fuctions are more of a branch.

initial code branches to the fuction and then comes back. Fuctions branch to other fuctions. etc etc. Think of it as sort of a Tree (like the side bar in Explorer for windows My Computer stuff) rather than standard replacement.
__________________

subliminal message: 1+1=3
Reply With Quote
  #5  
Old 05-18-2002, 10:53 PM
Bhala Bhala is offline
Disgruntled Monkey
Bhala's Avatar
Join Date: Mar 2001
Posts: 779
Bhala is on a distinguished road
Quote:
Originally posted by Kaimetsu
:-/

That's a misleading analogy. The internal working is nothing like that.
A true function works nothing like that but in Graal thats all they do.
Reply With Quote
  #6  
Old 05-18-2002, 11:03 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
Yes bhala, in graal thats exactly what it does, but it doesnt acually work like that =\.
__________________

subliminal message: 1+1=3
Reply With Quote
  #7  
Old 05-18-2002, 11:08 PM
Bhala Bhala is offline
Disgruntled Monkey
Bhala's Avatar
Join Date: Mar 2001
Posts: 779
Bhala is on a distinguished road
Whats the point of explaning the internal workings when all he needs to know is what it does?
Reply With Quote
  #8  
Old 05-18-2002, 11:31 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
Maybe to not rot out his mind if he wants to try other, more practical forms of programing like C++
__________________

subliminal message: 1+1=3
Reply With Quote
  #9  
Old 05-19-2002, 02:14 AM
Bhala Bhala is offline
Disgruntled Monkey
Bhala's Avatar
Join Date: Mar 2001
Posts: 779
Bhala is on a distinguished road
lol true...
Reply With Quote
  #10  
Old 05-19-2002, 02:24 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
Quote:
Originally posted by Kaimetsu
:-/

That's a misleading analogy. The internal working is nothing like that.
function parameters are suppose to be in the new scripting engine correct?
Reply With Quote
  #11  
Old 05-19-2002, 12:53 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 Kaimetsu
Don't hold your breath for it.
*thinks of 2k2*

I know better
Reply With Quote
  #12  
Old 05-20-2002, 11:03 PM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
Well about the new engine, a few weeks back Stefan said about a year...
Which sucks, however functions are very useful with classes and arrays.
I don't understand when people have a function that they only call once, because one of the points of functions is things you use more than once, like this:
NPC Code:

if (created || initialized) {
// Attributes restarted.
setarray this.stats, 100;
for (i=0; i<100; i++) setStatus();
}
function setStatus() {
this.stats[i] = random(-1, 1);
// do a lot of code so that calling a function isn't a waste of time
// they really are style things, it makes your code look more pretty.
return;
}



Now since this is a Graal function and Gscript, there is no real reason for the return, however I have always thought it should help with execution so that the function knows it has returned so it doesn't have to keep looking for code. In something more like PHP you may have code like this:
PHP Code:
function sql_conn($database) {
 
$user "user";
 
$pass "pass";
 
$host "localhost";
$connection mysql_connect($host$user$pass);
 if (
$connection) {
  
mysql_select_db($database); // See here it used the variable passed by the function.
  
return $connection;
 } else return 
0// Returning 0 is like returning saying the function didn't work.
}
if (
count($HTTP_POST_VARS)>0) {
 if (
$conn sql_conn("database_a"))
  echo 
"Wassup? mySQL is connected with connection id: $conn";
 else
  echo 
"Sadly mySQL didn't connect, it probably doesn't appreciate your stench.";

See fun fun fun functions. Well Hope that explaination helped, if thats even what you were asking, all you really need to do to pass "params" in fuctions is use callnpc, or you could just use this.vars since Graal has a global scope.
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
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 10:44 PM.


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