Author Topic: Getting Ghost Brick(client sided)  (Read 634 times)

How do I check if I have a ghost brick (client sided)?

You could try looking through build bots code not scarring yourself and waiting for nexus to pop in with the relevant bits.

I, personally, need to find my ghost brick and determine it's dimensions.


BuildBot's method of finding the ghost brick is horrible. If there's a brick closer to you than your ghost brick, everything breaks.

i know
do you happen to have a better method?

well, you could use nexus' method to find all the ghost bricks, move/change yours, and then check which ones move/change

BuildBot's method of finding the ghost brick is horrible. If there's a brick closer to you than your ghost brick, everything breaks.

I know, but it is literally the best option available without more input from user.  If there is another ghost brick of the same datablock closer, there is no way inside or outside of script to be sure just by looking at them for the first time.  I know that sometimes I'll be walking through my build and see a ghost brick, then try to clear it thinking it is mine, but it turns out someone left it there.  The script doesn't know something you don't, there just isn't a way to be sure.  I could probably revamp the code, though to include a check for the color of the ghost brick and something that locks your aim onto the ghost brick and asks "is this your ghostbrick?" and if you click no it locks onto the next one until it either runs out or you click yes.  However, that still cannot guarantee the correct one.

for the purposes of jes00, this should work well enough
Code: [Select]
if(!isobject(%pl = serverconnection.getcontrolobject()))
{
echo("Warning! You are not spawned.");
return 0;
}
%group = %pl.getgroup(); //I'm sure there is a better way, but meh.

%ppos = %pl.getposition();

for(%a=0; %a<%group.getcount(); %a++)

{

if((%b=%group.getobject(%a)).getclassname() $= "fxDTSBrick")

{

if(%b.isplanted() $= "0")

{

%gdist = vectordist(%b.getposition(), %ppos);

if(%gdist < %bestgdist || %bestgdist $= "")
{
%bestgdist = %gdist;
%ghost = %b;
}
}

}

}


if(%ghost $= "")
{
echo("No ghost bricks were found!");
return 0;
}
%pos = %ghost.getposition();
« Last Edit: April 14, 2012, 12:57:53 PM by Nexus »

You can also detect when a brick is ghosted to you and compare the time since you fired your brick tool.

You can also detect when a brick is ghosted to you and compare the time since you fired your brick tool.

Huh, well that is a good idea too, but it gets to the point where if there are a dozen different factors measuring different things that contribute to the guess (time, distance, datablock, where you looked to place a ghost brick, which one's movement most closely matches your commands, etc) that then there will need to be a complicated series of weighted probablilities and I'm happy with just using one and if it is wrong, oh well.