Can I combine a variable and a letter and call it from a resource?

Godot Version

4.3

Question

My project contains a lot of variables (70 to be exact) They are listed in this order.

I1, I2, I3 etc.

I have all of these stated in my resource, but when I call them to change them, I don’t want to call them all separately. This is what I have tried

for i in range(1, 70):
var resourcevariable = str(resource, “.I”, i)
resourcevariable = newvalue
But it doesn’t work.

Is there a way I can do this that would make it do what I want it to? If so, how?

This might be a duplicate topic of Can you construct a variable name with a string?

Do these two topics deal with different questions that would warrant two separate topics?

I’m attempting to use a string as a name for a variable in another script

Like, instead of

resource.variable1
resource.variable2
resource.variable3

I’d want to do something like this

for i in range(1, 71)
var nameofvariable = str(“variable”, i)
resource.nameofvariable

nevermind, I created a function inside of the resource itself which called a few pieces of data through a dictionary. I used

var nameofvariable = str(“variable”, i)
set(nameofvariable, value)

Thank you for the help on the other topic. It was the baseline of my solution for the entire save function of my code.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.