How to use a var "in" a var with GUI syntaxe?

Hi Folks,

Maybe a basic question, but i turn around since few days :smiley:

I’m trying to make the following things through GUI:
-I’m get a JSON from URL
-Store it in a VariableString
-Decod it in a GlobalVariableString
-Make a loop with integer number and use it in the GlobalVariableString syntax

Exemple:
A JSON like this:

[{
  "count":
 {
   "counter": "39"
 },
  "1":
 {
   "x": "100",
   "y": "120"
 },
 "2":
 {
   "x": "250",
   "y": "251"
 },
 "3":
 {
   "x": "68",
   "y": "49"
 },
 ...

VariableString: OK by using GET
Get the counter value OK: counttarget = ToNumber(GlobalVariableString(myjsonp.0.count.counter))
Define a count variable = 0

“But, here is my issue”:
GlobalVariableString(myjsonp.0.1.x) OK, it work like this (here result is “100”)

I’m trying to create a loop like:
while counttarget < count then:
GlobalVariableString(myjsonp.0.GlobalVariable(count).x)
Add 1 to count

Unfortunately, i get an error message in GUI, and it seems to not work.

I was able to do it following this method in Construct, maybe i can do it differently with Gdevelop?

Thanks a lot for your help!

I’m talking from my memory here
I think you have to split the string using another helper variable
like
(Scene Variable) temp_string = myjonp.0. + GlobalVariable(count) + .x
GlobalVariableString(templ_string)

Thx for your answer.

I found a way, i put it here if it can help. The main topic is to understand the variable and child concept (i was not ^^). We can put as var Child, while we can’t with variable itself. The doc on wiki explain it, but was hard to understand on my side.

ToString(GlobalVariable(myjsonp[0][ToString(Variable(count))].x))

Work like a charm :slight_smile: