Author Topic: Events/Too Far Questions  (Read 878 times)

There's a few things I haven't been able to work out about events. The first is saved with events, for some reason there's an extra gap, and I'm not sure whether there's something missing or it's unintended. I can't seem to replicate any circumstances where it's not empty.
Quote from: save file
+-EVENT   0   1   onActivate   0   Player   (There's a gap in between 2 tabs here)   AddHealth   25         

Again, there's another empty parameter which I can't work out, this time in the serverCmdAddEvent function. I can't find any circumstances where it's not blank.
Quote from: code
serverCmdAddEvent(%client, %enabled, %inputID, %delay, %targetID, ???, %outputID[, %param1[, %param2[, %param3[, %param4]]]]);

According to the update log for Blockland, since v1.03 the Too Far limit has been measured from the player to the edge of the brick rather than the middle.
Quote
"Too Far" planting limitation now checks against brick edge instead of center
I was wondering if there was an easy way to find the closest point to a player on the edge of a box (i.e. a brick), or preferably if anybody knows how the distance is currently calculated, rather than having to make complicated functions to do it.

Thanks in advance.

I don't think anything is missing.  It's probably unintentional.

Code: [Select]
serverCmdAddEvent(%owner,%enabled,%inputEventIdx,%delay,%targetIdx,%NamedTargetNameIdx,%outputEventIdx,<%args>);
« Last Edit: August 12, 2008, 09:26:02 PM by Trader »

This is untested, but it should be pretty close.

Code: [Select]
%xyz2 = %player.getPosition();
%x2 = getWord(%xyz2,0);
%y2 = getWord(%xyz2,1);
%z2 = getWord(%xyz2,2);

%brickMax = getWords(%brick.getWorldBox(),3,5);
%brickMin = getWords(%brick.getWorldBox(),0,2);

%brickMaxX = getWord(%brickMax,0);
%brickMaxY = getWord(%brickMax,1);
%brickMaxZ = getWord(%brickMax,2);

%brickMinX = getWord(%brickMin,0);
%brickMinY = getWord(%brickMin,1);
%brickMinZ = getWord(%brickMin,2);

if(%x2 - %brickMaxX < %x2 - %brickMinX)
{
%x1 = %brickMaxX;
}
else
{
%x1 = %brickMinX;
}

if(%y2 - %brickMaxY < %y2 - %brickMinY)
{
%y1 = %brickMaxY;
}
else
{
%y1 = %brickMinY;
}

if(%z2 - %brickMaxZ < %z2 - %brickMinZ)
{
%z1 = %brickMaxZ;
}
else
{
%z1 = %brickMinZ;
}

%x = (%x1 - %x2) * -1;
%y = (%y1 - %y2) * -1;
%z = (%z1 - %z2) * -1;

%distance = mSqrt(%x * %x + %y * %y + %z * %z);

That gap is incase you're using named brick I think.

That gap is incase you're using named brick I think.

Ah, nice.