Datablock changes?
by James Ford · in Torque Game Builder · 05/03/2007 (10:37 pm) · 3 replies
Have there been changes made to config datablocks? Are behaviors intended to completely replace them?
How can I get a sceneobject datablock to show up in the level editor? What script file do i need to create it in?
How can I get a sceneobject datablock to show up in the level editor? What script file do i need to create it in?
About the author
http://jamesdev.info
#2
05/04/2007 (4:07 pm)
I really doubt if they'll remove datablocks from TGB just because they have behaviors..they really aren't the same thing. Especially if/when TGB gets a networking overhaul. Datablocks aren't only convenient for initializing objects, they also are more efficient for sending data over the net. At least they are in TGE (so I've read).
#3
I am creating a player like this:
$player = new t2dAnimatedSprite()
$player.setConfigDatablock( NinjaConfig );
$scenegraph.addToScene($player);
And the NinjaConfig datablock contains the behavior the player should have.
Update:
Ok, adding behaviors with a datablock--that is assigned in the level editor--works
My question involves adding behavior with a datablock--that is assigned in script. That is, how? And why isnt mine working '-)
05/05/2007 (3:40 pm)
Is it a problem to assign behaviors with datablocks? They seem to be added, but they aren't actually doing anything. Does this have to do with the order behavior/datablocks are assigned Patrick was talking about?I am creating a player like this:
$player = new t2dAnimatedSprite()
$player.setConfigDatablock( NinjaConfig );
$scenegraph.addToScene($player);
And the NinjaConfig datablock contains the behavior the player should have.
Update:
Ok, adding behaviors with a datablock--that is assigned in the level editor--works
My question involves adding behavior with a datablock--that is assigned in script. That is, how? And why isnt mine working '-)
Torque 3D Owner Patrick Shaw
I don't know what "the plan" is for config datablocks, but I hope they aren't replaced because its easy to copy one config datablocks to each another. For example, I can defined baseDatablock -> entityDatablock -> playerDatablock - > playerWarriorDatablock. I suppose I can do the same with behaviors, but config datablock seem to be much easier.
I have a basic way (ie maybe not the best) way to add config datablocks in beta 3:
1) Put all of your config datablocks into a single *.cs file.
2) Copy that file to your behaviors directory so that the file is run in the for both your game and the level editor
3) Currently, when you run your game, Beta3 assigns the config datablock assigned in the level editor AFTER it runs the behaviors. This cause problems for my project so I created a behavior similar to this:
if (!isObject(assignDatablock)) { %template = new BehaviorTemplate(assignDatablock); %template.friendlyName = "Assign Datablock"; %template.behaviorType = "game"; %template.description = "Assigns a config Datablock to the objet"; %datablocks = "entityDataBlock" TAB "enemyDatablock" TAB playerDatablock; %template.addBehaviorField(config, "The configuration datablock", enum, "entityDataBlock", %datablocks); } function assignDatablock::onAddToScene(%this, %scenegraph) { %this.owner.setConfigDatablock(%this.config); }