Empty datablock & declaring conobjects
by David Spuhler · in Torque Game Engine · 08/12/2005 (4:39 am) · 5 replies
I am designing a torque interface to another piece of software that should be given sensory input from a game and send steering information to the game...
In order to create a sensor i inherited from GameBase to make use of the processTick() method. as a consequence i have to define a datablock SensorData.. Actually
i do not need this datablock so i tried to define an empty datablock. unfortunatly there is a problem creating an empty datablock in my script:
it does work when i introduce a dummy variable in my SensorData class:
is there a more elegant way to solve this problem??
Another problem:
I want define an object as a console object that has a constructor with a nonzero number of parameters. How can i manage that?
From the documentation i know how to create an object with such a constructor in the console... But how do i have to declare it in the engine code?
Thanks for your help!
In order to create a sensor i inherited from GameBase to make use of the processTick() method. as a consequence i have to define a datablock SensorData.. Actually
i do not need this datablock so i tried to define an empty datablock. unfortunatly there is a problem creating an empty datablock in my script:
datablock SensorData(SensorTestData)
{
};it does work when i introduce a dummy variable in my SensorData class:
datablock SensorData(SensorTestData)
{
dummy = 1;
};is there a more elegant way to solve this problem??
Another problem:
I want define an object as a console object that has a constructor with a nonzero number of parameters. How can i manage that?
From the documentation i know how to create an object with such a constructor in the console... But how do i have to declare it in the engine code?
Thanks for your help!
#2
Error:
%
>>> Some error context, with ## on sides of error halt:
%
datablock SampleObjectData(TestData)
{
}##;##
Error:
%
>>> Some error context, with ## on sides of error halt:
%
datablock SampleObjectData(TestData)
{
;##
##};
Error:
%
>>> Some error context, with ## on sides of error halt:
%
datablock SampleObjectData(TestData);##
##
Concerning the parametrized constructor: here is my problem:
when i try to compile the following sources
i get this Error:
--> Compiling game/sampleObject.cc
console/consoleObject.h: In member function 'ConsoleObject*
ConcreteClassRep::create() const [with T = SampleObject]':
game/sampleObject.cc:34: instantiated from here
console/consoleObject.h:330: error: no matching function for call to '
SampleObject::SampleObject()'
game/sampleObject.cc:18: error: candidates are:
SampleObject::SampleObject(const SampleObject&)
game/sampleObject.cc:45: error: SampleObject::SampleObject(int)
make[1]: *** [out.GCC3.DEBUG/game/sampleObject.obj] Error 1
make: *** [default] Error 2
what am i doing wrong? how to i have to declare the parametrized constructor?
08/19/2005 (11:50 am)
Concerning the empty datablock issue i have tried the following versions:datablock SampleObjectData(TestData)
{
};Error:
%
>>> Some error context, with ## on sides of error halt:
%
datablock SampleObjectData(TestData)
{
}##;##
datablock SampleObjectData(TestData)
{
;
};Error:
%
>>> Some error context, with ## on sides of error halt:
%
datablock SampleObjectData(TestData)
{
;##
##};
datablock SampleObjectData(TestData);
Error:
%
>>> Some error context, with ## on sides of error halt:
%
datablock SampleObjectData(TestData);##
##
Concerning the parametrized constructor: here is my problem:
when i try to compile the following sources
#include "game/gameBase.h"
struct SampleObjectData : public GameBaseData
{
private:
typedef GameBaseData Parent;
public:
SampleObjectData();
// S32 dummy;
DECLARE_CONOBJECT(SampleObjectData);
};
class SampleObject : public GameBase
{
private:
typedef GameBase Parent;
public:
SampleObject(S32 param);
DECLARE_CONOBJECT(SampleObject);
};
IMPLEMENT_CO_NETOBJECT_V1(SampleObjectData);
SampleObjectData::SampleObjectData()
{
}
IMPLEMENT_CO_NETOBJECT_V1(SampleObject);
SampleObject::SampleObject(S32 param)
{
}i get this Error:
--> Compiling game/sampleObject.cc
console/consoleObject.h: In member function 'ConsoleObject*
ConcreteClassRep
game/sampleObject.cc:34: instantiated from here
console/consoleObject.h:330: error: no matching function for call to '
SampleObject::SampleObject()'
game/sampleObject.cc:18: error: candidates are:
SampleObject::SampleObject(const SampleObject&)
game/sampleObject.cc:45: error: SampleObject::SampleObject(int)
make[1]: *** [out.GCC3.DEBUG/game/sampleObject.obj] Error 1
make: *** [default] Error 2
what am i doing wrong? how to i have to declare the parametrized constructor?
#3
08/19/2005 (3:25 pm)
Have you looked at processArguments? From the SimObject docs:virtual bool processArguments(S32 argc, const char **argv); ///< Process constructor options. (ie, new SimObject(1,2,3))
#4
what do you think about the dummy datablock? is there a solution to create an empty datablock?
08/20/2005 (1:13 am)
Ben: thank you so much! that was the perfect solution to my parametrized constructor problem.what do you think about the dummy datablock? is there a solution to create an empty datablock?
#5
08/20/2005 (3:01 pm)
It's probably some odd thing in the grammar. The dummy solution is fine; it won't cost you anything more than 4 bytes per instance, and no processing/networking overhead.
Associate Kyle Carter
datablock SensorData(Foo : Bar, param1, param2, param3) { };Don't know about the null-datablock issue. Is it failing with any particular error?