Author Topic: Complex Bricks [Solved]  (Read 1226 times)

Because I have no loving clue how to work out Blender nor the .blb files, I decided to go oldschool.

I've got this
Code: [Select]
function buildComplexBrick(%brk, %client, %i) {
echo(1);
%bricks = %brk.getDatablock().complexBuild[0];
echo(2);
//while(i < %bricks) {
%data = getField(%brk.getDatablock().complexBuild[i],0);
%rx = getField(%brk.getDatablock().complexBuild[i],1);
%ry = getField(%brk.getDatablock().complexBuild[i],2);
%rz = getField(%brk.getDatablock().complexBuild[i],3);
%col = getField(%brk.getDatablock().complexBuild[i],4);
%rota = getField(%brk.getDatablock().complexBuild[i],5);
%rotb = getField(%brk.getDatablock().complexBuild[i],6);
%rotc = getField(%brk.getDatablock().complexBuild[i],7);
%rotd = getField(%brk.getDatablock().complexBuild[i],8);
%print = getField(%brk.getDatablock().complexBuild[i],9);
echo(3);
%newbrick = new fxDTSBrick() {
dataBlock = %data;
scale = "1 1 1";
client = %client;
stackBL_ID = %client.BL_ID;
angleID = "0";
colorID = %col;
colorFXID = "0";
//shapeFXID = "0";
isPlanted = true;
rotation = %rota TAB %rotb TAB %rotc TAB %rotd;
print = %print;
};
echo(4);
%newbrick.setTransform(%brk.x+%rx SPC %brk.y+%ry SPC %brk.z+%rz);
echo(5);
%newbrick.plant();
%newbrick.setTrusted(1);
echo(6);
%client.brickGroup.add(%newbrick);
echo(7);
%i++;
//schedule(0,0,"buildComplexBrick",%brk, %client, %i);
//}
}

and in the test datablock, the following:

Code: [Select]
complexBrick = true;
complexBuild[0] = 2;
complexBuild[1] = "bick2x2Data 0.5 0.5 0.4 48 rot1 rot0 rot0 rot0 0";
complexBuild[2] = "brick2x2crestLowdata 0.5 0.5 1 45 rot1 rot0 rot0 rot0 0";
//format: Datablock retaliveX relativeY relativeZ color rot1 rot2 rot3 rot4 printID

Now, here's the thing. I swear on my Blockland Key that I have no clue what is wrong with the code. Whenever I get the ID of a brick to try out buildComplexBrick();, it returns the following in the console:
Code: [Select]
1
2
3

base/server/scripts/allGameScripts.cs (21116): Unable to find object: '0' attempting to call function 'onRemove'
BackTrace: ->buildComplexBrick->fxDTSBrick::onRemove

Add-Ons/Server_[secret, lol]/server.cs (68): Register object failed for object (null) of class fxDTSBrick.
4

Add-Ons/Server_[secret, lol]/server.cs (70): Unable to find object: '0' attempting to call function 'setTransform'
BackTrace: ->buildComplexBrick

5

Add-Ons/Server_[secret, lol]/server.cs (72): Unable to find object: '0' attempting to call function 'plant'
BackTrace: ->buildComplexBrick


Add-Ons/Server_[secret, lol]/server.cs (73): Unable to find object: '0' attempting to call function 'setTrusted'
BackTrace: ->buildComplexBrick

6
Set::add: Object "0" doesn't exist
7

So the brick isn't created. Alright. Except that I don't know what causes it to not create. Particularly because of fxDTSBrick::onRemove which isn't in my code and I doubt it has something to do with new fxDTSbrick();

Could someone point me in the right direction? I've used the search function and compared codes but one of the two solutions isn't posted and the second one is pretty hard to interpret because the OP posted parts of his code instead of the entire function.
« Last Edit: March 04, 2015, 12:27:40 PM by Pie Crust »

Scale and rotation values are space delimited, not tab
I don't think that would stop the brick from being created though; it should just default everything else to 0

%data = getField(%brk.getDatablock().complexBuild[i],0);
%rx = getField(%brk.getDatablock().complexBuild[i],1);
%ry = getField(%brk.getDatablock().complexBuild[i],2);
%rz = getField(%brk.getDatablock().complexBuild[i],3);
%col = getField(%brk.getDatablock().complexBuild[i],4);
%rota = getField(%brk.getDatablock().complexBuild[i],5);
%rotb = getField(%brk.getDatablock().complexBuild[i],6);
%rotc = getField(%brk.getDatablock().complexBuild[i],7);
%rotd = getField(%brk.getDatablock().complexBuild[i],8);
%print = getField(%brk.getDatablock().complexBuild[i],9);


you forgot the % for i

%data = getField(%brk.getDatablock().complexBuild[i],0);
%rx = getField(%brk.getDatablock().complexBuild[i],1);
%ry = getField(%brk.getDatablock().complexBuild[i],2);
%rz = getField(%brk.getDatablock().complexBuild[i],3);
%col = getField(%brk.getDatablock().complexBuild[i],4);
%rota = getField(%brk.getDatablock().complexBuild[i],5);
%rotb = getField(%brk.getDatablock().complexBuild[i],6);
%rotc = getField(%brk.getDatablock().complexBuild[i],7);
%rotd = getField(%brk.getDatablock().complexBuild[i],8);
%print = getField(%brk.getDatablock().complexBuild[i],9);


you forgot the % for i


By extension of this, creation of the brick fails because %data = ""

Damn it. So much time trying to figure out something so stupid. Thanks guys.

I have no idea what most of this means, but I caught a typo:

Code: [Select]
complexBrick = true;
complexBuild[0] = 2;
complexBuild[1] = "bick2x2Data 0.5 0.5 0.4 48 rot1 rot0 rot0 rot0 0";
complexBuild[2] = "brick2x2crestLowdata 0.5 0.5 1 45 rot1 rot0 rot0 rot0 0";
//format: Datablock retaliveX relativeY relativeZ color rot1 rot2 rot3 rot4 printID

bick2x2Data

Yes, I noticed that but it dumped a warning that it didn't exist instead of the other ambiguous error.



If only Torque would output a stuffload of syntax errors when you forget the % instead of defaulting to Null, I would be so happy.

If only Torque would output a stuffload of syntax errors when you forget the % instead of defaulting to Null, I would be so happy.
It's completely valid syntax as far as Torque cares.
It interprets it as you wanting %array["i"]