Game Development Community

Curious - Difference between Methods & Expressions in script events

by Jacob S. · in Verve · 06/16/2010 (11:03 am) · 1 replies

What is the difference between Methods & Expressions in script events?

Methods aren't what I'd expected them to be, I tried calling a console "Method" as a Method and I found I needed to call it as an Expression for it to be evaluated.

Also it doesn't seem to be in the docs so if you could shed some light on that it would be great.

#1
06/16/2010 (3:54 pm)
I wrote up a small explanation for the tutorial:

www.violent-tulip.com/dev/?doc-type=tutorial&tutorial-name=Torque%20Script%2...

The method type will invoke a method call on the underpinning object, or when there is none, it will invoke a function call:
// No object referenced by the group (should only happen for the DirectorGroup)
myFunctionName();

// %myObject is the object referenced by the group.
%myObject.myMethodName();

The expression will just evaluate the script, just like using the eval command in Torque Script:
eval( "$Game::Variable = 10; myFunctionName();" );