View Single Post
  #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