Game Development Community

TorqueScripting > Add new Method to a Class

by Bauer Ren · in Torque Game Engine · 12/07/2005 (5:38 am) · 3 replies

After working with Torque I have some questions about Torque and Torquescripting and OOP:

- If I understand all the things right, the Torquescript is not really OOP?

-- You can generate Instances, delete etc. Exec methods. Add Fields etc. But you can't generate own Classes in Torque Scripts or add some new Methos to a Class. Is this correct?

-- and if not how can i add new methods in Torque Script? Examples?

-- if it is so, i have to change the c++ code, i suppose.

Thanks for reply

Ren

#1
12/07/2005 (7:18 am)
tdn.garagegames.com/wiki/TorqueScript

And do a quick find in your Web Browser for Console Methods

And as a quick answer to your question, you do not have to change the C++ code to add in new methods in TorqueScript.

Be sure to check TDN and search here on the forums before asking a question ;).

Hope it helps,

- Eric
#2
12/07/2005 (7:51 am)
Basically, you can create namespaces and associate methods to them. Them you can link certain kinds of objects to a a certain namespace, and the methods defined in that namespace will be avaliable to the object.

Datablocks and ScriptObjects/ScriptGroups are the main objects that support that kind of namespace linking.

The objects' very own names can be linked to namespaces of the same name too.
#3
12/07/2005 (9:15 am)
@ eric: if you are coming from languages like java or something similiar it is a good question and there is no page or something where you have for example a comparision between torque script and something like java or c# or c++. so it is not easy to get into torque for example scripting (c++ is not so complicate) and believe me i have read and searched a lot but there is still no really clear answer to my questions till now. it's not at all clear and there are - in my opinion - no really documents, which focus from top to bottom the whole torque engine. and the engine could be much more popular if there would be a simple . but this is just a note - i am interesting in finding out, how the whole thing works. for you: it's perhaps easy, but for an outsider it's really hard.

perhaps therefore i ask for all the other persons, who have the same problem.

and what i found out is written down in my message at the top.

- consolescripts are global-scripts for the whole range of the engine
- manoel describes a type to make "something" like object-orientated classes/objects, where you can add scripts to a namespace

i will look at the following link
http://tdn.garagegames.com/wiki/TorqueScript/Namespaces

@manoel: do you have some links for good examples?

thanks for your reply, but it's not so easy
Ren