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):
         myArray[i][j]=rand_range(0,1)

Thank you

in Engine by (2,100 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 (204 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 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 webmaster@godotengine.org with your username.