0 votes

Hi all,

I'm trying to do the following:

func setup_board():
    for x in range(5):
        board.append(['O']*5)

... but I get this error:

Invalid operands 'Array' and 'int' in operator '*'.

Can anyone point to what's going wrong here? I understnad it's saying something like I can't perform a multiplication on an Array but I'm doing a python tutorial and this works in Python. In that case, how would I do it in GDScript? I should probably note that I'll be replacing 'O' with a sprite in time. This is just a quick prototype.

BTW, in Python this is the output and what I'm basically trying to achieve:

['O', 'O', 'O', 'O', 'O']
['O', 'O', 'O', 'O', 'O']
['O', 'O', 'O', 'O', 'O']
['O', 'O', 'O', 'O', 'O']
['O', 'O', 'O', 'O', 'O']

Any advice greatly appreciated.

asked Aug 31, 2016 in Engine by Robster (808 points)
edited Aug 31, 2016 by Robster

1 Answer

+1 vote
Best answer

Hi, this issue has already been discussed:
https://godotengine.org/qa/5122/how-do-i-create-a-2d-array

answered Aug 31, 2016 by ludosar (275 points)
selected Sep 1, 2016 by Robster

Thank you, much appreciated and sorry I didn't see that one earlier.

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.