Can variable name's be altered in runtime?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By D
:warning: Old Version Published before Godot 3 was released.

Is their any way to concatenate variable names at runtime? I would like to be able to set variable’s in loops. As example.

var a0 = null
var a1 = null

for i in range(1):
     ai = 5

Where ai would be the concatenated variable. I can’t find any way to make it work.

Thanks.
D

For that specific case, why not just use an array?

var a = [null, null]

for i in range(1):
    a[i] = 5

Could you provide an example where using an array wouldn’t be nice?

raymoo | 2017-03-10 19:19

:bust_in_silhouette: Reply From: YeOldeDM
var a0 = null
var a1 = null

for i in range(1):
     set( "a" + str(i), 5)

If you must do it this way.

Maybe you should… promote the right way of using variables in loops too…
This is horrible…

Omicron | 2017-03-13 18:15