0 votes

I'm kind of new to programming and I want to know if there is a way without a for loop to discovery and use the index of an array.

Example:
var clock = [orange, yellow, abc, ..., ]

If clock index is 2:
print ("spiderman")

in Engine by (129 points)

I dont understand the question. An array is an object with components inside. Each component has an index asociates. You want to see what the 'current' index of an array is? Well, You will have to create and modify the index yourself. If you tell me what you want to acomplish, may be i can help you more

There's no such thing as "discovering an index of an array". No offense but it really does sound like you're a beginner at programming. Read this and this, and come back later.

1 Answer

0 votes

want to know if there is a way without a for loop to discovery and use the index of an array.

You can program your own data structure, that keeps track of the indexes for you, adding the functionality.

Instead I will recommend using Dictionaries, these have a index that you can just call when you want.
https://docs.godotengine.org/en/3.0/classes/class_dictionary.html

by (1,445 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.