Game Development Community

Function overloading in TS

by Gennady · in Torque 3D Beginner · 05/14/2011 (12:52 pm) · 2 replies

Hi all!
I'm trying to understand the mechanics of internal function invocations in Torque and here's one trouble in the face functions' overloading. From the C++' times there was a rule, that overloaded functions must differ one from another by the list of arguments. But what we've got here - a lot of functions with one name, one list of arguments (null) and different inner code. My Codeweaver without any doubt call these function overloaded. So, the name - is not my goal. I'd want to know how the engine "understand" which function it ought to invoke?

Example: the most simple that everyone saw (I suppose). Template, first main.cs, in the end of this file there is an invocation of function on Start(). But this function exist in 3 files.

It will be great if somebody explain me how it works!
Thanks!

About the author

Specialist of International center for professional training in Rosatom Technical Academy


#1
05/16/2011 (9:43 pm)
The purpose of the script overrides, and packages, is simply to provide a means of extending or overriding certain functions either by namespace or package overrides. The onstart() function you mention has a default, then the core package can override that. The game package once it starts up also has an override. It seems convoluted at first but is really quite simple if you think of the game going through certain stages with anything falling into game package containing the logic and mechanics of your game. The core you can think of as the infra-structure that all/most games need to make use of. The 'top' most package is the one that has first level control of what function to use, but by using a parent command you could walk up the chain of overrides.

#2
06/03/2011 (7:50 am)
To add a bit to the Mich explanation, you can also have a server function and client function with the same name, and not having interference between them.