Blockland Forums > Modification Help
How do I place bricks when a player is close to a fall?
<< < (2/2)
Axolotl:

--- Quote from: Port on March 18, 2012, 05:31:07 AM ---Am I the only one who read the OP completely?

I don't see this text anywhere:

--- End quote ---
Yeah, I want the bricks to generate when a player stands or walks into a non-generated area.


--- Quote from: Nexus on March 18, 2012, 04:11:25 AM ---I'm know there are a couple of terrain generators you can poke around through that do this, ill just throw in my terragen mod, mostly because I can't think of any others at the moment that are public.
http://dl.dropbox.com/u/20459676/client_terragen.zip

Start looking through the terragen_tick function, specifically line 230

--- End quote ---
It's a little too complex because I don't know what the functions do.

Can I please have a standalone code that places 4x4f bricks in a flat plane when I stand or walk into a non-generated area?
Axolotl:
oops doublepost
Treynolds416:

--- Quote from: Port on March 18, 2012, 05:31:07 AM ---Am I the only one who read the OP completely?

--- End quote ---
He said "Like in a terrain generator", and was not too specific, so I assumed he was using it for a terrain generator. I also used the word "probably" in my post as an indicator that I wasn't completely sure what he was asking.

Ninja: Title also is "How do I place bricks when a player is close to a fall?"
Nexus:

--- Quote from: Axolotl on March 18, 2012, 07:13:34 AM ---It's a little too complex because I don't know what the functions do.

Can I please have a standalone code that places 4x4f bricks in a flat plane when I stand or walk into a non-generated area?

--- End quote ---

I'll walk you through the core process

--- Code: ---//from the tick function, called constantly on a loop
for(%c=0; %c<terragen.adventurercount; %c++)
{
if(isobject(%b = terragen.adventurer[%c]))
{
%gpos = terragen_getgridpos(terragen_getplayerpos(%b));
%xi = getword(%gpos, 0);
%yi = getword(%gpos, 1);

for(%a=$terragen::radius*-1; %a<=$terragen::radius; %a++)
{
for(%b=$terragen::radius*-1; %b<=$terragen::radius; %b++)
{
%x = %xi + %a;
%y = %yi + %b;

if(!terragen.plangrid[%x, %y])
{
terragen_addgridbricks(%x,  %y); //adding mega meat...
}
}
}
}
else
terragen_remove(%c);
}
--- End code ---
This loops through all players, and for each player it does another loop to determine if any grid spaces in a certain radius of them have not been set.  This will be the core of what you want.


Once you have determined that a grid space needs something on it, generate that grid space
The function terragen_addgridbricks(%x, %y) is alot more complicated than you need to worry about, because it also adds numerous little details and smoothing and stuff.  Basically once you know the xy coordinate, it should be pretty straightforward to figure it out on your own.
Navigation
Message Index
Previous page

Go to full version