Game Development Community

Several questions.

by Yue -Rookie Torque 3D- · in Torque 3D Beginner · 09/07/2013 (12:50 pm) · 4 replies

What are modules?
What are classes?
Hierarchy classes are?
What are the classes members?
What are namespaces?
What are the namespaces members?



Appreciate a response as detailed as possible.

About the author

http://www.iris3d.tk -Games Studios- <<I do not speak English: I use the google translator>> My goal as a rookie is knowing Torque 3D


#1
09/07/2013 (1:05 pm)
I have a few questions:

Classes in TorqueScript or classes in C++?

Which namespaces? Torque's specific ones or C++ namespaces or what?

"Hierarchy classes?" Do you need the class inheritance information for a particular class or are you needing a definition of what a class hierarchy is?

If you need the Torque class hierarchies you can actually find most of them in the documentation - just click the "Reference Guide" link at the top of the left column, then find the class you want and it should have the information there.

"Modules" - hmm. This term has a number of different definitions depending on which product you're talking about.

Class members are data or methods that belong to a class. http://www.cplusplus.com/doc/tutorial/classes/
#2
09/07/2013 (1:41 pm)
Thanks for your answer, I speak specifically of torque script.

Actually I'm trying to clarify all about torque Scripts.
#3
09/07/2013 (3:10 pm)
In Torquescript classes are used to group methods. The class name is a "namespace" defining the "space within which methods associated with this name are referenced." So, a class name is a namespace. A script class can be assigned to an object at object creation (but not after) to associate all of the class's methods with that object to allow myClass::myMethod() to work on objects created with myClass to call %myObject.myMethod().

// create myMethod in myClass namespace
function myClass::myMethod(%this)
{
    %this.enabled = false;
}

// create script object with class myClass
%obj = new ScriptObject()
{
    class="myClass";
}

// call myClass::myMethod() on %obj
%obj.myMethod();

// now %obj.enabled is false

Namespaces within Torquescript can also be applied to global variables to help organize global information. $pref::maxPlayers and $pref::maxScore are both global variables that use the "pref" namespace to organize maxPlayers and maxScore. Really, in this use they are just name decorators and not actual "namespaces" in the accepted sense, but that's not really important.

As the C++ documentation states, class members are data and methods belonging to the class. I don't believe that script classes directly contain member data but you can attach fields to the object using %this.

function myClass::setMyVal(%this, %val)
{
    %this.value = %val;
}

function myClass::getMyVal(%this)
{
    return %this.value;
}

%obj = new ScriptObject()
{
    class="myClass";
}

// sets the value field on the object to 10
%obj.setMyVal(10);

// prints the data stored in the value field of %obj to the console
echo( %obj.getMyVal() );
#4
09/07/2013 (7:00 pm)
Greatly appreciate your help. :)