The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hi, I need get size the array into another array(2d array)...Something like getsizerow
For example:

for i in range (myArray_get_size_row):
     for j in range(myArray_get_size_column):

Thank you

in Engine by (2,260 points)

2 Answers

+1 vote
Best answer

In gdscript I would do:

for i in range(myArray.size()):
    for j in range(myArray[i].size()):
        myArray[i][j] = rand_range(0, 1)
by (210 points)
selected by

The only disadvantage is that you have to use a loop for, but it works ... I have to get used to using the arrays inside the arrays without thinking about arrays2D ...
Sorry for my english and thank you very much for answering.

0 votes

Here's a way I did it without looping

var max_element = array_to_check.max()
var last_element = array_to_check.back()
var cols = max_element.x if max_element.x > last_element.x else last_element.x
var rows = max_element.y if max_element.y > last_element.y else last_element.y
by (16 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.