Torque 3D 3.7
ContentsIndexHome
PreviousUpNext
ConsoleObject Class
ConsoleObjectConsoleObjectConsoleObjectConsoleObject
Syntax
C++
class ConsoleObject : public EngineObject;

Interface class to the console. 

@section ConsoleObject_basics The Basics 

Any object which you want to work with the console system should derive from this, and access functionality through the static interface. 

This class is always used with the DECLARE_CONOBJECT and IMPLEMENT_* macros. 

@code // A very basic example object. It will do nothing! class TorqueObject : public ConsoleObject { // Must provide a Parent typedef so the console system knows what we inherit from. typedef ConsoleObject Parent; 

// This does a lot of menial declaration for you. DECLARE_CONOBJECT(TorqueObject); 

// This is for us to register our fields in. static void initPersistFields(); 

// A sample field. S8 mSample; } @endcode 

@code // And the accordant implementation... IMPLEMENT_CONOBJECT(TorqueObject); 

void TorqueObject::initPersistFields() { // If you want to inherit any fields from the parent (you do), do this: Parent::initPersistFields(); 

// Pass the field, the type, the offset, and a usage string. addField("sample", TypeS8, Offset(mSample, TorqueObject), "A test field."); } @endcode 

That's all you need to do to get a class registered with the console system. At this point, you can instantiate it via script, tie methods to it using ConsoleMethod, register fields, and so forth. You can also register any global variables related to the class by creating a consoleInit() method. 

You will need to use different IMPLEMENT_ macros in different cases; for instance, if you are making a NetObject (for ghosting), a DataBlock, or a NetEvent

@see AbstractClassRep for gory implementation details. @nosubgrouping

Copyright (c) 2015. All rights reserved.
What do you think about this topic? Send feedback!