Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   Params Problem (https://forums.graalonline.com/forums/showthread.php?t=66823)

JustBreathe 06-22-2006 10:52 AM

Params Problem
 
PHP Code:

NPC1:

function 
onCreated()
  {
  
foo"bar" ); // returns false;
  
}

public function 
foo()
  {
  
NPC2.bar"foo" );
  return 
params;
  } 

PHP Code:

NPC2:
function 
onCreated()
  {
  
NPC1.foo"bar" ); // returns "foo,";
  
}

public function 
bar()
  {
  return 
params;
  } 

Inconsistency 1:
When called from within the function, params variable is NOT set. When called outside, it IS set.

Inconsitency 2:
When calling an external function, params variable are overwritten. ( Should be kept the same within the process )


Temp Fix 1: Use function foo( param1, param2 ), but limits the amount of params you COULD potentially have!

Temp Fix 2: temp.oparam = params; foo(); params = temp.oparam;

Admins 06-22-2006 02:46 PM

The params[] array is only set when a script function is called from outside, or when an event is invoked on a gani script (and you are using if (playerenters) etc. instead of onPlayerEnters). There is also only one params[] for the whole script engine, so it gets overwritten. It would be too slow to copy the function parameters to a separate array on each function call, also there are many scripts relying on the fact that you can access the original params[] array in subfunctions.

JustBreathe 06-22-2006 02:48 PM

Quote:

Originally Posted by Stefan
The params[] array is only set when a script function is called from outside, or when an event is invoked on a gani script (and you are using if (playerenters) etc. instead of onPlayerEnters). There is also only one params[] for the whole script engine, so it gets overwritten. It would be too slow to copy the function parameters to a separate array on each function call, also there are many scripts relying on the fact that you can access the original params[] array in subfunctions.

Wouldn't it be possible to do like the real params? Use the temp.params = params; at the start of each function? ( therefore, params would be local to the function ? )


All times are GMT +2. The time now is 11:30 PM.

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