Can someone make a 2d array extension?

I don’t usually ask people to make a whole project for me, but I had trouble with this. I want a small extension that has the following blocks:

A way to set an array:
image
Or any other way. (sorry for the bad drawing)

A way to add columns and rows to the beginning or end.

A way to set a value to something else.

That’s it!

If you make it, thanks a lot!

Also,
Can it be so that you can’t add individual cells, but only columns and rows?

Thanks again!

1 Like

You can have nested arrays:


And you can access them like this:
image
And do whatever you normally would do with regular arrays.

Note that you cannot have a blank array of arrays:


Because the type checker wouldn’t know what type it is.

1 Like

I know of this, but when I try to do things like this, It produces many errors.

In my case, I first initialize a two-dimensional array, and then store the values there.

let putCardMap: number[][] = null

putCardMap = [[],[]]

//Init Map
for(let i = 0; i < 5; i++) {
    putCardMap[i] = []
    for(let j = 0; j < 5; j++) {
        putCardMap[i][j] = null
    }
 }

//set value
putCardMap[posX][posY] = currentCardNo

Could you share the project that errors out a lot? I do this alot.

Here!

1 Like