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

Why is my loop stopping?

Asked by 8 years ago

If you need any extra info, I will post it.

I am using the PolyDraw Module BTW.

So, I am running a loop. And it stops running after going through only a couple of times.

function SetChunkSize(NX, NY)
    print("SettingChunkSize")
    local Chunksize = ChunkSize
    local Tilesize = TileSize

    if NX == -1 or NX == 1 or NY == -1 or NY == 1 then
        Chunksize = Vector2.new(((Chunksize.X-1)/2)+1, ((Chunksize.Y-1)/2)+1)
        Tilesize = Tilesize * 2
    elseif NX == -2 or NX == 2 or NY == -2 or NY == 2 then
        Chunksize = Vector2.new(((Chunksize.X-1)/4)+1, ((Chunksize.Y-1)/4)+1)
        Tilesize = Tilesize * 4
    end

    print(Chunksize.X .. ":" .. Chunksize.Y .. "_" .. Tilesize)
    return Chunksize, Tilesize
end

local function GenerateTriangles(XOffset, YOffset, NX, NY, Chunksize)
    local Chunk = Instance.new("Model", game.Workspace)
    Chunk.Name = XOffset .. ":" .. YOffset

    for X = 0, Chunksize.X-1 do
        if X ~= Chunksize.X-1 then
            for Y = 0, Chunksize.Y-1 do
                if Y ~= Chunksize.Y-1 then
                    print(X .. ":" .. Y)
                    local A, B, C, D = Chunks[Chunk.Name][X .. ":" .. Y], Chunks[Chunk.Name][X + 1 .. ":" .. Y], Chunks[Chunk.Name][X .. ":" .. Y + 1], Chunks[Chunk.Name][X + 1 .. ":" .. Y + 1]
                    local Tri1 = PolyDraw.Tri.new(Chunk, A, B, C)
                    local Tri1 = PolyDraw.Tri.new(Chunk, B, C, D)
                end
            end
        end
        if First == false then wait() end
    end
end

NOTE: This is not the whole script. The loop is in the GenerateTriangles function. Anyone know why it stops?

Output: Player:-1, 0 SettingChunkSize 3:3_512 0:0 0:1 0:2

0
Is there any error? About how big is `Chunksize.X` and `Chunksize.Y`? BlueTaslem 18071 — 8y
0
The chunksize is a Vector two of 17 x 17 at first. I have no errors also. I do know that it works as it was not until tonight that it stopped working. I was implementing the change of the tilesize as the chunks would be less detailed. MisaMiner 50 — 8y

Answer this question