Game Development Community

Unable to call function setTimerOn(solved)

by KaiserImpact · in Torque 2D Beginner · 01/05/2014 (4:00 am) · 7 replies

Hello all. As a newbie in torque2d programming, I am here to ask a simple question regarding setTimerOn function. I am unable to call this function somewhat in my program.

So what i did is i've initialized %this.setTimerOn(5000); in my function TestToy::create(%this). And i've created a onTimer function.

function onTimer(%this)
{
%this.setTimerOff(); //stop the timer
%this.printInput(); //execute timer action
}

my printInput is just an echo to display a message.

However after running the program the following error appeared in my console output
"modules/TestToy/1/main.cs (39): Unknown command setTimerOn.
Object TestToy(1266) TestToy -> SimSet -> SimObject"

Am i lacking of something else?

#1
01/05/2014 (6:20 am)
Hi, couple corrections to make:

setTimerOn and setTimerOff do not exist - they are called startTimer and stopTimer. Then for your onTimer callback, it needs to be given a namespace since the timer belongs to an object. So change the function to TestToy::onTimer.
#2
01/05/2014 (6:27 am)
Oh wait. means the functions at http://docs.garagegames.com/it2d/official/content/documentation/Introduction/Reference/t2dSceneObject.html were already outdated?
#3
01/05/2014 (8:08 am)
"Already?" If you're using T2D MIT then those docs have been "outdated" since early 2011 because you're looking at the docs for a different engine.

T2D MIT and iT2D are very similar, but don't let that fool you. They are most definitely not the same. T2D MIT is far faster and is vastly improved in other ways over iT2D. Some of those changes presented an opportunity to streamline and clean up some of the basic functionality in the engine - removing "t2d" from the beginning of everything (like t2dSceneObject becomes just SceneObject) is one of the more wide-spread changes.

While sparse at the moment, the place to look for T2D MIT documentation is the T2D GitHub Wiki. Once you're familiar with the basics it'll be easier to apply information from older documentation to your projects - you'll be able to recognize and adapt outdated code samples more easily.
#4
01/05/2014 (8:11 am)
@KaiserImpact - Those are the older TGB docs. Many of those functions have been deprecated, while others had their function signature change. Mike's post has the actual functions you should use.

Edit - Quickdraw Richard beat me to it =)
#5
01/05/2014 (8:31 am)
Yes, those docs are for iTorque, which was an older iOS only version of the engine. The best place to find current documentation is on the Github wiki:

github.com/GarageGames/Torque2D/wiki

Under the TorqueScript section is a reference guide which lists all the class functions.

Basically any documentation here on the GG site is outdated and should only be used by those with older versions of the commercial engines.

Edit: don't worry Mich, I got beat by both you and Richard!

@Richard - and I wouldn't call the wiki docs sparse, we're pretty much on par or better than the older engine docs. :P
#6
01/05/2014 (1:11 pm)
That's good news - I haven't looked at that page in a while.
#7
01/07/2014 (6:45 am)
Thanks guys for correcting me! Appreciated it very much. Thread closed.