Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why does generating Smooth Terrain via scripts result in a holey map?

Asked by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

Basically, I have a grid of many 15x15 Parts. I use code to edit these Parts' color and Y size, somewhat randomly. I then use the color and size of the Parts to generate Smooth Terrain with the correct size and material.

The regular Parts are changing color and size just fine. However, when I go to generate the Smooth Terrain, for some reason the map is full of holes. It's doesn't make a lot of sense.

This is my grid of regular Parts.

This is what happens when I edit their size and color, prepping for the terrain generation.

This is what happens when I generate the terrain. See the holes? Currently I just manually made the Parts invisible so you can see the terrain clearly, although they will eventually be getting deleted after the terrain is formed.

This is the function I use for generating terrain based on the properties of the Parts:

function smoothTerrain()
    --'loaded' is just a Model filled with all the correctly colored and sized Parts.
    for i, part in ipairs(loaded:GetChildren()) do
        if part.BrickColor == BrickColor.Blue() then
            workspace.Terrain:FillBlock(part.CFrame, part.Size, "Water")
        elseif part.BrickColor == BrickColor.Green() then
            local shape = math.random(1, 2)
            if shape == 1 then
                workspace.Terrain:FillBlock(part.CFrame, part.Size, "Grass")
            else
                workspace.Terrain:FillBall(part.Position, part.Size.Y/2, "Grass")
            end
        else
            workspace.Terrain:FillBlock(part.CFrame, part.Size, "Sand")
        end
    end
end

How can I fix this holey map?

0
It may be an bug on ROBLOX's side. dyler3 1510 — 9y
0
Hope not. Perci1 4988 — 9y
1
That seems quite odd. Try changing ipairs to pairs or changing line 11 to use the X or Z position, maybe? Not too sure. Spongocardo 1991 — 9y
0
That actually helps, not using the Y, since the height will never be larger than the width. Still having some issues, but thanks. Perci1 4988 — 9y
View all comments (2 more)
0
I would use RbxUtitily for that, because really workspace.Terrian does have a bug and ROBLOX just never fixed it yet. :/ MessorAdmin 598 — 9y
0
RbxUtitily? explain please? Perci1 4988 — 9y

1 answer

Log in to vote
-3
Answered by 9 years ago
function smoothTerrain()
    --'loaded' is just a Model filled with all the correctly colored and sized Parts.
    for i, part in ipairs(loaded:GetChildren()) do
        if part.BrickColor == BrickColor.Blue() then
            workspace.Terrain:FillBlock(part.CFrame, part.Size, "Water")
        elseif part.BrickColor == BrickColor.Green() then
            local shape = math.random(1, 2)
            if shape == 1 then
                workspace.Terrain:FillBlock(part.CFrame, part.Size, "Grass")
            else
                workspace.Terrain:FillBall(part.Position, part.Size.Y/2, "Grass") -- nope.
            end
        else
            workspace.Terrain:FillBlock(part.CFrame, part.Size, "Sand")
        end
    end
end

You do it right in FillBlock but in FillBall you do it wrong. (I've noticed no balls are shown)

Replace the

part.Position

with

part.CFrame

wich leads to

function smoothTerrain()
    --'loaded' is just a Model filled with all the correctly colored and sized Parts.
    for i, part in ipairs(loaded:GetChildren()) do
        if part.BrickColor == BrickColor.Blue() then
            workspace.Terrain:FillBlock(part.CFrame, part.Size, "Water")
        elseif part.BrickColor == BrickColor.Green() then
            local shape = math.random(1, 2)
            if shape == 1 then
                workspace.Terrain:FillBlock(part.CFrame, part.Size, "Grass")
            else
                workspace.Terrain:FillBall(part.CFrame, part.Size.Y/2, "Grass")
            end
        else
            workspace.Terrain:FillBlock(part.CFrame, part.Size, "Sand")
        end
    end
end

Sorry, I can't fully explain why this happens since I'm not a CFrame expert, but I do know CFrame is not Position!

Hope this helps! Thanks, marcoantoniosantos3.

1
No, that method takes a Vector3, according to the wiki. http://wiki.roblox.com/index.php?title=Smooth_terrain#FillBall Perci1 4988 — 9y
0
i dunno then :/ marcoantoniosantos3 200 — 9y
Ad

Answer this question