How to equate the text of a Child Variable to aText of a Text object?

This is what wiki says
wiki


here are my events

And these are Scene Variables

Not only this but i also tried in some other ways but none of that worked, i only saw a blank instead of hello,
when I did this

I do got hello displayed but that is not what i want, i want it to take number from Variable “CurrentLevel”.
So how to do this…??

wiki told: children of a (variable) structure. you are want to use two independent variables insead of a variable structure. it can be possible, but of course the syntax what is designed for a structures will not work with a simple variable.

and I think you should convert the whole expession to text when you are want to display it with a text object. so add a “ToString” to the beginning.

I do used different syntax!as metioned in wiki


What does it mean when you said two independent variables instead of a variable structure??
Adding ToString at the beginning is not working :frowning:

Can you or anyone else try to do this in gdevelop, and also there is no example available explaining this.
Maybe @arthuro555 @Lizard-13 can help?

1 Like

VariableString(PlayerStats[“Level” + ToString(Variable(CurrentLevel))])

HaHA… i just sent you a PM about this exact thing. hope it helped.

use it in your events like this.

isArray.age
isArray.name

its not really an array but I think you get the point.

2 Likes

This did helped me because i didnt knew that we can directly add child variables by clicking on that plus, Thank You so much for this!
But thats not the actual solution to my problem!

1 Like

glad it helped a little

1 Like

Sorry for being late here, but what is the problem? I saw the first post and the second solution seems right, if it isn’t what you want, what do you want exactly? Do you want it to be reversed maybe, judging by the title? What is your exact goal?

This is what I want:- First imagine there are 100 child variables, and they are named as PlayersStats.Level1, PlayersStats.Level2…PlayersStats.Level100.

There will be a variable, in this situation its “CurrentLevel”, which will be storing a randoming generated number from 1 to 100. For now i just stored 1 in Variable “CurrentLevel” in scene variables window.

Each Child variable of “PlayersStats” will be storing a text, I want that text to shown on the screen based on the value of Variable “CurrentLevel”.

So first i follwed what wiki says and I also did VariableString(PlayersStats[“Level”+ToString(Variable(CurrentLevel))] ) to the text as @Gyuszko said ,but idky that does not seem to be working!

Also when we do a error in gedevelop it warns and shows us what might be wrong, Its also warning now but I am not able to find where that error is, everything looks simple and it should be working but idky its not working!

there should be a syntax error, because it work for me.
see yourself:
https://www.mediafire.com/file/hgcf99l2h8u059e/structure.json/file

1 Like

Thank you so much, its working now! I found what was wrong, i will post it here!!Thank You again!!

1 Like

This is the one which was not working!
this

And this one is the working one!xD
thislol

Can you find the difference? I honestly don’t what created this or how this happened, lol
Thank You helping me out everyone!

You were not using the right symbol for ". You used the ” one Wich is invalid and only used in normal text, not in code. Be more careful in the future that " looks like two “sticks” that are not incurvated.

2 Likes

Yup :slight_smile: :slight_smile: