Blockland Forums > Modification Help
Problem with circle generator.
otto-san:
I misunderstood.
It does round the player's position.
EDIT:
--- Quote from: Chrono on September 15, 2011, 04:53:30 PM ---for example, a starter brick.
--- End quote ---
I can think of multiple ways to probably do this but I don't know how to exactly do any of them.
So to retain most of what can be done with this right now, how can I get the position of a player's temporary brick?
phflack:
you could just use it to start off the movement of your brick, instead of moving it to a specific location
Red_Guy:
This seems to work -- but its a bit laggy when the circles get big
--- Code: ---function Player::dobrickstuff(%player, %pos, %datablock)
{
%playerPos = %player.tempBrick.getPosition();
%position = vectorAdd(%playerPos, %pos);
%brick = new fxDTSBrick()
{
client = %player.client;
datablock = %datablock;
position = %position;
rotation = "0 0 0 0";
colorID = %player.client.currentColor;
scale = "1 1 1";
angleID = "0";
colorfxID = "0";
shapefxID = "0";
isPlanted = 1;
stackBL_ID = %player.client;
};
%brick.setTrusted(1);
%brick.plant();
%player.client.brickGroup.add(%brick);
}
function makeEllipse(%player, %r1, %r2, %scale, %addedZ)
{
%steps = (3.14159265 * %r1 * %r1) / 0.5;
%inc = 360 / %steps;
echo("%r1: " @ %r1 @ " steps: " @ %steps @ " inc: " @ %inc);
if(%r2 > 0)
{
for(%i = 0; %i < 360; %i+= %inc)
{
%x = %r1 * mFloatLength(mCos(mRadToDeg(%i)), 6);
%y = %r2 * mFloatLength(mSin(mRadToDeg(%i)), 6);
%player.doBrickStuff(%x SPC %y SPC 0 + %addedZ, Brick1x1Data);
}
}
else
{
for(%i = 0; %i < 360; %i+= %inc)
{
%x = %r1 * mFloatLength(mCos(mRadToDeg(%i)), 6);
%y = %r1 * mFloatLength(mSin(mRadToDeg(%i)), 6);
%player.doBrickStuff(%x SPC %y SPC 0 + %addedZ, Brick1x1Data);
}
}
}
function serverCmdMakeCircle(%client, %r1, %r2)
{
if ( !isObject(%client.player.tempBrick) )
{
messageClient(%client, '', "place a ghost brick first");
return;
}
makeEllipse(%client.player , %r1, %r2, 0);
}
function serverCmdCircleTest(%client)
{
for ( %a=5; %a < 50; %a+=4)
{
serverCmdMakeCircle(%client, %a, %a);
}
}
--- End code ---
and it really only works properly when %r1 = %r2
to fix -- consult your math book and lookup the formula for the circumference of an ellipse, then adjust the forumla accordiingly.
the magic number here is 0.5 - the width of a 1x1 brick.
place a brick and type /circletest to see it in action