Well, Not sure how well one is able to use Terrain:ReadVoxels and Terrain:WriteVoxels. for this as I personalyl have never tried it, but you might be able to try that.

The idea being you Terrain:ReadVoxels in a given area to get all the grass terrain and then replace them using Terrain:WriteVoxels.

Scripting Terrain - Reading and Writing Voxels

Unless you’re looking to have grass in certain regions and snow in others I personally would select the whole region for the map and set said terrain matching grass to snow. Likewise if you want to sweep an area in sections you could run a loop that goes up in the X axis.

Example: I have a region of 10 x 10 x 10 centered at 0,0,0. I want to go + on the X axis 2 times each region having a different terrain set.

I know that since the region is a 10 x 10 x 10 square that on the left side (X-) it goes to -5 and on the right side it goes to 5 (X+) for the X axis. For depth (Z) it does the same thing, goes to 5 on Z+ and -5 on Z-. Same thing for the Y axis 5 on Y+ and -5 on Y-.

Now I just need some sort of function or formula that can give me the center of the next region.

In this case POS will be the initial starting position in this example we’re staying on the X axis. and REPT going left/Right. Obviously the down side is we’re stuck on one Axis currently.

F(POSX,SIZE,REPT) = POSX + (SIZE* REPT)

So long as we know our Z Axis we can use this in one direction going left to right, so let’s put some numbers in.

F(0,10,1) = 0 + (10*1)*

F = 10

F(0,10,2) = 0 + (102)

F = 20

Now that we have values for the center of region on the X axis we can go X- by 1/2 of SIZE and X+ by 1/2 of SIZE on the X axis to get the Region Corners. Keep in mind we haven’t changed our Z so for F(0,10,2) we’re at 20,0,0 (X,Y,Z).

Taking 1/2 of SIZE on X- gets us 15. so thats 15,0,0 now if we take 1/2 of SIZE and add it to the Z axis we get the top right corner which is 15,0,5.

Now lets get the bottom left corner.

We take 20 and add 1/2 half of SIZE to it and get 25 for our X axis now we take 1/2 of Size again and subtract it from the Z axis and get -5 for that. Puting numbers together we get 25,0,-5 for the bottom left. That gets us what the region bounderies are which can be useful for many things.

the included picture shows what the region would look like. the parts are 1x1x1

Since regions do this math for bounderies for us we just need the center position and size of the region. F(POSX,SIZE,REPT) gets us the position on the X axis.

However, we’re still stuck going left and right on the X axis and cant make any progress with the Z Axis. I personally would take the first region we started with and say I want to go Z+ would take

Z and add the SIZE to it. if we’re at 0,0,0 for the center that means the next region above that is at

0,0,10. so long as SIZE = 10.

We’d do the same thing for the Y axis as well.

Here’s a Lua function:

```
-- return center of region
function regionCenter(x,y,z,size,rept)
local z = 0
local x = 0
local y= 0
local poss = {}
x = x + (size * rept)
z = z + (size * rept)
y = y + (size * rept)
poss = {x,y,z}
return poss
end
```

Sorry if this was a bit confusing, thought it would be good to cover how a region is actually calculated before getting the center of a region. Hopefully this gives you an idea of where to go with looping through a region. Let me know if you run into any problems or have any questions.