Static Persistant Fields
by William Todd Scott · in Torque Game Engine · 02/02/2006 (8:32 pm) · 2 replies
Hi All,
I have a custom shape object that has fields that are accessible via script. Some of the data members are static and thus effect every object. I made one of the static data members accessible via script. My hope is that the user can select one of the objects in the mission editor and change some of these class wide static data members. However, when I change the field in script it only appears to be changed on the one object....wierd.
Here are the code snippets:
In initPersistFields():
addGroup("Global Forest Settings");
addField("dropToBillboard", TypeBool, Offset(s_bDropToBillboard, CSpeedTreeWrapper));
endGroup("Global Forest Settings");
In packUpdate():
stream->writeFlag(s_bDropToBillboard);
In unPackUpdate():
s_bDropToBillboard = stream->readFlag();
Do I need to handle this field differently because it is static?
Thanks
Todd
I have a custom shape object that has fields that are accessible via script. Some of the data members are static and thus effect every object. I made one of the static data members accessible via script. My hope is that the user can select one of the objects in the mission editor and change some of these class wide static data members. However, when I change the field in script it only appears to be changed on the one object....wierd.
Here are the code snippets:
In initPersistFields():
addGroup("Global Forest Settings");
addField("dropToBillboard", TypeBool, Offset(s_bDropToBillboard, CSpeedTreeWrapper));
endGroup("Global Forest Settings");
In packUpdate():
stream->writeFlag(s_bDropToBillboard);
In unPackUpdate():
s_bDropToBillboard = stream->readFlag();
Do I need to handle this field differently because it is static?
Thanks
Todd
Torque 3D Owner Stephen Zepp
You would then need to have your objects refer to the global variable in their various class implementations.
An example of this would be something like the sRenderMyPlayer global variable for the Player class (implemented in Player.cc), and it's corresponding mapping to pref::Player::renderMyPlayer in Player::consoleInit().