Suggestion: Call a function of a differen script
prwo
Member Posts: 69
Currently, ExecuteScript always and only invokes the main function of the provided script. It would be very useful if the function to be actually executed could be provided as well. This would allow to call an arbirary function of another script.
E.g.
This would allow to group related functions together in a script instead of making own files for each and every one of them.
Further advances would be to allow for the scripts to return values (int, object, ...) to the caller.
(Maybe this idea was posted in another sub-thread alredy, but I couldn't find it anymore.)
E.g.
a_script.nss:
void MyFunction1 ()
{
// Do something here
}
another_script.nss:
...
ExecuteScript("a_script", oObject, "MyFunction");
This would allow to group related functions together in a script instead of making own files for each and every one of them.
Further advances would be to allow for the scripts to return values (int, object, ...) to the caller.
(Maybe this idea was posted in another sub-thread alredy, but I couldn't find it anymore.)
0
Comments
Note: The mentioned thread describing a workaround to pass "return values" back from a script to the calling script is: Suggestion: Call a conditional script from within another script and evaluate its return value
The same technique can be used to pass parameters from a script to the called script. Such a parameter could contain a reference to function to be executed by the called script. The main() of the called script would evaluete the parameter an execute the corresponding function.
By the way: the latest version of AuroraExt contains an NSS preprocessor that can automatically generate such proc/func/event dispatcher scripts automatically.
... if the Aurora Toolset would separate the build system from the editing part such language extenders could be integrated rather easily by everyone.