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

My world generation script will only generate grass can anybody help?

Asked by
kom297 -4
6 years ago

It only generates grass spires i dont see why it is not working

my script:

--Static variables
local prefabs = game.ServerStorage.Prefabs
local cubes = 90
local width = 10
local length = 10
local height = 5
local x = -0.5
local y = 1.5
local z = 1.5
local rows = 1
local w = 0
local l = 0
local h = 0
local chance = 0
math.randomseed(tick())

--Void
function DrawBlock(block, xp, yp, zp, location, num)
    if num == "" then
        local newBlock = prefabs[block]:Clone()
        newBlock.Parent = location
        newBlock.Size = Vector3.new(2,2,2)
        newBlock.CFrame = CFrame.new(xp,yp,zp)
    else
        local newBlock = prefabs[block]:Clone()
        newBlock.Parent = location
        newBlock.CFrame = CFrame.new(xp,yp,zp)
        newBlock.Size = Vector3.new(2,math.random(3,10),2)
    end
end

for i=1,width,1 do
    for i=1,length,1 do
        wait()
        if w==width then
            w=0
            rows=rows+1
            x=x-3
            z=1.5
            print(l)
            l=l+1
        elseif l == length and h ~= height then
            w=0
            l=0
            z=1.5
            y=y-3
            x=0.5
            for i=1,width,1 do
                for i=-1,length,1 do
                    for i=1,height,1 do
                        wait()
                        if w==width then
                            w=0
                            rows=rows+1
                            x=x-3
                            z=1.5
                            print(l)
                            l=l+1
                        elseif l == length then
                            print(h)
                            h=h+1
                            w=0
                            l=0
                            x=1.5
                            z=0.5
                            y=y-3
                        elseif h == height then
                            break
                        else
                            chance = math.random(0,3)
                            if chance < 1 and chance > 0.6 then
                                DrawBlock("Copper",x,y,z, workspace.World, "")
                            elseif chance < 1 and chance > 0.5 then
                                DrawBlock("Stone",x,y,z, workspace.World, "")
                            end
                            w=w+1
                            z=z+(-3)
                        end
                    end
                end
            end
            repeat wait() until h == height
            break
        else
            chance = math.random(0,3)
            if chance < 0.15 then
                DrawBlock("Grass",x,y,z, workspace.World, chance)
            elseif chance < 1 and chance > 0.5 then
                DrawBlock("Stone",x,y,z, workspace.World, chance)
            end
            w=w+1
            z=z+(-3)
        end
    end
end
0
really stupid question, but do you have your game in filteringenabled mode? Inevitable_Judgement -10 — 6y
0
FE is default now User#5423 17 — 6y
0
^ LOL that is definitely not the reason why he can't "Change it", i'd change DrawBlock's first parameter to something else greatneil80 2647 — 6y
0
I meant ^^* greatneil80 2647 — 6y
View all comments (3 more)

Answer this question