Author Topic: Detect when a brick is rendered? [SOLVED]  (Read 596 times)

I'm fairly new to scripting with Torque, and was wondering how to detect when a brick has been rendered after being generated via scripts? I noticed there is a delay between generating a brick (creating the object and collision box) and actually rendering it. This is what I was thinking (just taking a single column into account for now), but it doesn't initiate the echo command:

Code: [Select]
for(%cz=0;%cz<=%RowHFSB;%cz=%cz+2)
{
%brick = new fxDTSbrick()
{
datablock = brick4xCubeData;
colorID = 45;colorFXID = 0;shapefxID = 0;isPlanted = 1;rotation = "0 0 0 0";scale = "1 1 1";angleID = 0;
client = %client;stackBL_ID = %client.bl_id;
position = (%cpx+%cx) @ " " @ (%cpy+%cy) @ " " @ %cz;
};
%simgroup = new simGroup(){name = "Server";bl_id = %client.bl_id;};
mainBrickGroup.add( %simgroup );
%simgroup.add( %brick );
%brick.setTrusted(1);%brick.plant();%brick.setRayCasting(0);%brick.setColliding(0);
}
if(%brick.setRendering==true)
{
echo("brick rendered!");
}

I was hoping to create a chunk-based terrain generation script that waits for all the bricks (or just the last brick) in a single chunk to be rendered before moving on to the next chunk - otherwise the game freezes. Thanks!
« Last Edit: February 04, 2013, 12:39:22 PM by [GSF]Ghost »

What you mean by "rendering" is actually called Ghosting.

It's a completely client-sided process, which means that there is no way to detect when a client has ghosted a specific brick.

Ok, I guess the only thing I can do is to set a timed-delay between loading the chunks. Thanks for the help.

package foo
{
   function fxDTSBrick::onPlant(%this)
   {
      %r = parent::onPlant(%this);
      talk("bar");
      return %r;
   }
};activatepackage(foo);



i think this is what you mean.

Just add a 100ms delay between each chunk. That should be a long enough delay to allow the game to get other calculations done and not freeze.

I tried the timed-delay and it works just fine. I had a timed delay before, but accidentally put it inside of a loop function, which made it delay and then run through all the calculations at once. Thanks again for the help guys.