Blockland Forums > Modification Help
Auto Falling Plates code not making plates fall.
<< < (3/6) > >>
Mold:

--- Quote from: phflack on June 03, 2012, 01:13:15 PM ---
--- Code: ---%brick = MainBrickGroup.getObject(%i);

--- End code ---
i feel like %brick is a brickgroup, not an actual brick
do another for loop similar to the first, to be more like

--- Code: ---for(%a = 0; %a < MainBrickGroup.getCount(); %a++)
{
    for(%b = 0; %b < MainBrickGroup.getObject(%a).getCount(); %b++)
    {
         %brick = MainBrickGroup.getObject(%a).getObject(%b);
    }
}

--- End code ---

--- End quote ---
No

Or?
Port:

--- Quote from: Mold on June 03, 2012, 04:15:41 PM ---No

Or?

--- End quote ---

What?



--- Quote from: phflack on June 03, 2012, 01:13:15 PM ---
--- Code: ---%brick = MainBrickGroup.getObject(%i);

--- End code ---
i feel like %brick is a brickgroup, not an actual brick
do another for loop similar to the first, to be more like

--- Code: ---for(%a = 0; %a < MainBrickGroup.getCount(); %a++)
{
    for(%b = 0; %b < MainBrickGroup.getObject(%a).getCount(); %b++)
    {
         %brick = MainBrickGroup.getObject(%a).getObject(%b);
    }
}

--- End code ---

--- End quote ---

Please learn to optimize your code. For every group of bricks, you're calling mainBrickGroup.getCount() and for every single brick, you're calling mainBrickGroup.getObject(index) twice and mainBrickGroup.getObject(index).getCount().


--- Code: ---%group_count = mainBrickGroup.getCount();

for ( %i = 0 ; %i < %group_count ; %i++ )
{
%group = mainBrickGroup.getObject( %i );
%brick_count = %group.getCount();

for ( %j = 0 ; %j < %brick_count ; %j++ )
{
%brick = %group.getObject( %j );
}
}

--- End code ---
phflack:

--- Quote from: Port on June 04, 2012, 01:42:25 AM ---Please learn to optimize your code. For every group of bricks, you're calling mainBrickGroup.getCount() and for every single brick, you're calling mainBrickGroup.getObject(index) twice and mainBrickGroup.getObject(index).getCount().


--- Code: ---%group_count = mainBrickGroup.getCount();

for ( %i = 0 ; %i < %group_count ; %i++ )
{
%group = mainBrickGroup.getObject( %i );
%brick_count = %group.getCount();

for ( %j = 0 ; %j < %brick_count ; %j++ )
{
%brick = %group.getObject( %j );
}
}

--- End code ---

--- End quote ---
just saying an example, and in other programming languages it's done automaticaly, probably not in torquescript though
there's no reason to tell others to optimize their code for posting a basic example which is easy to read
elm:

--- Quote from: phflack on June 04, 2012, 03:51:12 PM ---there's no reason to tell others to optimize their code for posting a basic example which is easy to read

--- End quote ---

...Yes there is...
phflack:

--- Quote from: elm on June 04, 2012, 09:06:39 PM ---...Yes there is...

--- End quote ---
optomized code is better for released addons, while if you're helping somebody learn something like this, it's easier to read the way i posted it
so, no there isn't
Navigation
Message Index
Next page
Previous page

Go to full version