Game Development Community

Difference between ConsoleMethod and DefineEngineMethod?

by Jean-louis Amadi · in Torque 3D Professional · 04/14/2011 (5:44 am) · 5 replies

Hello, i wish to know what is the difference between ConsoleMethod and DefineEngineMethod? I'm not sure to understand but the both create a console access to referenced object in the engine i think.

#1
04/14/2011 (6:10 am)
DefineEngineMethod is new in Torque 3D, where before all TorqueScript calls to the engine were made using ConsoleMethod (for classes) or ConsoleFunction (for globals). They both accomplish about the same thing in code. From what I understand, one of the differences is that DefineEngineMethod is not variadic where as ConsoleMethod is. I'm not sure the actual technical details on why they have moved to using DefineEngineMethod's instead.
#2
04/14/2011 (6:24 am)
In short, ConsoleMethod/Function dumps all the internals of the interop on you. You need to handle all the string conversions, default args, prototype docstring construction, etc. yourself. engineAPI with its DefineEngineMethod/Function does that all for you.

There's a bunch more to this but this is one of the reasons why using engineAPI is better.
#3
04/14/2011 (6:55 am)
ConsoleMethod is good for backward compatibility.
If you have hundreds of methods and if you need to port them to the new format,then this would be really bad for you.
#4
04/14/2011 (7:19 am)
ConsoleMethod: you can define you function, this function is not in class.
DefineEngineMethod: class must be have this function
#5
04/14/2011 (7:41 am)
Thank you very much all for all these details ;)

I have a small bunch of methods and with these details in mind i will port my code to DefineEngineMethod.