Game Development Community

Function scope in Torque scripting language

by Tim Lei · in Torque Game Engine · 04/20/2002 (12:01 am) · 2 replies

Hi, I have some newbie questions.

In the example\common\main.cs,
I saw the following function:
activatePackage( )

I probably know its purpose. However, where is this function defined? If it is some sort of build-in function, how is it build-in?

A more genenrally question, is the scope of a function defined in a file limited to that file only? or is it visible too all files?

Thanks

#1
04/20/2002 (8:55 am)
Functions and $variables have global scope. The only locally scoped scripting feature is the %variables which have function scope.

$Global = 100;

function foo(%local)
{
%anotherLocal = 1;
$Global = 200;
}

The activate package is a C++ function built in to the engine. There are quite a few built in C++ functions, and C++ methods on objects as well as misc. support functions defined in scripts. There is no way to tell the difference by looking at the name :) If I'm not clear on a function, I usually do a global search through all the .cs files in the example dir (and sub-dir). It helps to have an code editor with good searching features :)
#2
04/20/2002 (3:14 pm)
Oh, now things become a lot more clear :)

Is there actually a reference to the build-in functions?
I actually tried to search the engine codes to see if there is definition of the build-in functions, but when I search word by word, like "activatePackage", I found nothing really. I am searching through all the files included in the Torque SDK Workspace using VC6.

Also is it possible that I can write a function in C++, then make it a build-in function in the script?

Thanks!!!