How get key from list ?
Hello
I have list of list:
dialogText["friend"] = [
"1 2: Hello! What’s the problem? Can I help you?",
"2 1: Oh, I lost my friend. I don’t know where it is. ",
"3 2: What does your friend look like? "
]
dialogText["ball"] = [
"1 2: Hello! What’s the problem? Can I help you?",
"2 1: Oh, I lost my ball. I don’t know where it is. ",
"3 2: What does your ball look like? "
]
how to get list: ['friend','ball']
???
Ou, I was need declare arr like that before:
dialogText = ["bike","mobile","friend","ball"]
dialogText["friend"] = [
"1 2: Hello! What’s the problem? Can I help you?",
"2 1: Oh, I lost my friend. I don’t know where it is. ",
"3 2: What does your friend look like? "
]
dialogText["ball"] = [
"1 2: Hello! What’s the problem? Can I help you?",
"2 1: Oh, I lost my ball. I don’t know where it is. ",
"3 2: What does your ball look like? "
]
and dialogText is my list
thats work, but without dialogText = ["bike","mobile","friend","ball"]
isnt work
Lists don't support keys. They are just arrays, like python lists. (The editor doesn't throw an error when trying to use keys on lists, but it should.)
You can do key-value pairs with objects
dialogText = object
friend = [
"1 2: Hello! What’s the problem? Can I help you?",
"2 1: Oh, I lost my friend. I don’t know where it is. ",
"3 2: What does your friend look like? "
]
ball = [
"1 2: Hello! What’s the problem? Can I help you?",
"2 1: Oh, I lost my ball. I don’t know where it is. ",
"3 2: What does your ball look like? "
]
bike = [
// bike texts
]
mobile = [
// mobile texts
]
end
and then you can use it like dialogText["friend"]
or dialogText.friend
. It will work both ways.