Blockland Forums > Modification Help
Getting Ghost Brick(client sided)
<< < (2/2)
Nexus:

--- Quote from: Port on April 13, 2012, 02:43:08 PM ---BuildBot's method of finding the ghost brick is horrible. If there's a brick closer to you than your ghost brick, everything breaks.

--- End quote ---

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: --- 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();
--- End code ---
Port:
You can also detect when a brick is ghosted to you and compare the time since you fired your brick tool.
Nexus:

--- Quote from: Port on April 14, 2012, 01:49:05 PM ---You can also detect when a brick is ghosted to you and compare the time since you fired your brick tool.

--- End quote ---

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.
Navigation
Message Index
Previous page

Go to full version