0 votes

So, I'm aware that the term "object" might have a different meaning in gdscript then it has in web development (vue/javascript) where I usually work. Which is why I have been having a hard time framing the question appropriately. I think the best way to explain what I am asking would just be to show you want I want to do. This is what I would want:

array = [
{name: Jack, age: 21},
{name: Jill, age: 24},
{name: Trump, age: 7}

return array[0] = {jack, 21}

As I understand it arrays in gdscript can't do this? Or can they and I just don't know how? And if they can't is there something else that I can use to do this instead of arrays?

Edit: Actually never mind. I figured it out. I just forgot to put the labels in quotes, lol. This is how you do it:

array.append({"name": "Jack", "age": 21})

in Engine by (31 points)

Note that what you're doing here specifically is making an array of dictionaries.

You don't need quotes on identifiers if you assign with =

var array = [
        name = "Jack",
        age = 21

Yes, but this only works for string keys, while dictionaries can use many data types for keys. I don't recommend jumping between Python dictionary syntax and Lua table syntax - it only leads to confusion.

Thank's for that clarification by the way. Actually really helps to know how to frame things when you are googling for answers to problems.

Please log in or register to answer this question.

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 webmaster@godotengine.org with your username.