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

2D Array not possible?

Asked by 6 years ago

I cant use a 2d array because every time i define the 2 array inside it resets the array and I want the array to save all the values not reset everytime the loop runs. But there isnt a way to define grid[i] without resetting it?

grid = {}

    for i = -radius,radius do
        grid[i] = {} -- Problem, resets not stores.
        for j = -radius,radius do
            local part = game.ReplicatedStorage.Grass:Clone()
            if math.sqrt(math.pow(i,2)+math.pow(j,2))<radius and (grid[i][j] == 0 or not grid[i][j]) then -- Pythagoras for circle algorithm
            print("Placing..")

                --CFame here(Too complicated to put in sample)

                grid[i][j] = 1

                part.Parent = game.Workspace.Chunk
            else
                part:Destroy()
                grid[i][j] = 0
            end
        end
    end
0
This would be much easier to understand if you break down what each part of the script does exactly. Seems a bit too much for me, HA! lazycoolboy500 597 — 6y
0
How exactly are you figuring out that it doesn't store the table? yyyyyy09 246 — 6y

Answer this question