I couldn't figure out how to fix this. So I guess I have no choice but to come here.
This function is called after the save has finished loading. I had to call this alternate function 1 millisecond after the real function, because the events aren't on the bricks yet.
This function is supposed to take two variables from bricks and, when appropriate, create a static shape going from one to the other.
$BlockHeadBash::TileBricks is a list of the possible bricks.
The bricks have to variables:
%brick.secondaryName - The secondary name of the brick.
%brick.BlockheadBash_linked - A list of secondary names for that brick to "link" to by creating the static shapes that goes from
%brick to the brick with that secondary name.
The problem I'm having is, too many static shapes are being created. Some are extra and overlap. Some are extra, overlap, and are too long. And there are some extra that are going from one to another, when they shouldn't exist.
function ServerLoadSaveFile_AfterEnd()
{
%count = getWordCount($BlockheadBash::TileBricks);
for(%i = 0; %i < %count; %i++)
{
echo("\c2%i:" SPC %i);
%brick = getWord($BlockHeadBash::TileBricks, %i);
if(!isObject(%brick))
{
$BlockHeadBash::TileBricks = removeItemFromList($BlockHeadBash::TileBricks, %brick);
continue;
}
%count2 = getWordCount(%brick.BlockheadBash_linked);
for(%a = 0; %a < %count2; %a++)
{
echo("\c2%a:" SPC %a);
%secondaryName = getWord(%brick.BlockheadBash_linked, %a);
for(%b = 0; %b < %count; %b++)
{
%brick2 = getWord($BlockheadBash::TileBricks, %b);
echo("\c2%b:" SPC %b);
if(%brick2 == %brick)
{
continue;
}
if(%brick2.secondaryName == %secondaryName)
{
BlockheadBash_createLine(%brick.getPosition(), %brick2.getPosition(), $BlockheadBash::lineThickness, $BlockheadBash::lineZOffset, $BlockheadBash::lineColor);
}
}
}
}
}
Below is a diagram to help you understand what I mean.
There are seven extra static shapes that shouldn't exist and most are overlapping existing ones(including the ones in the middle). There's also one going from A to C which shouldn't exist(it should stop at B and then a new one should go from B to C).