Sorry english is not my language
i tried to use GlobalVariable and Variable but dont know how to work
first, i randomly choose variable text and then it effects to global variable
i want to show the changed global variable value
so i think that to show all of random global variable string case, put variable string
(in the pic, variablestring(RandomA)=A, so Globalvariablestring(variablestring(RandomA))=Globalvariablestring(A)… i think…)
but some kind of reasons, it is not work
i think there is something wrong with the part, but I dont get it
Sorry english is not my language
You need to change the class1_result = GlobalVaribleString(A)
According to your logic here you assign to variable A some random letter
then check if randomLetter = “A”
change global A -=5
then assign to text variable class1_result the value of global A and show class1_result
Tip instead of naming A to the global try to name it score or Score or Points
instead of naming RandomA just name it RandomLetters
You can’t access a variable by using a string. Notice it’s Variable(RandomA), and not Variable(“RamdomA”). The VariableString function puts the result in quotes.
[edit, after @Silver-Streak’s comment ]
If you need to access the values using a string as the identifier, look at using a structure :
As MrMen mentioned above, it is not possible to dynamically access a top level variable voa expression. The full name must be used.
If you are wanting to dynamically call variables, you will need to make a top level structure variable, and then make all of your other variables children of that structure. You xan then dynamically access the children. You can read more on dynamic access in the variable page on the wiki.
hi me again
thanks for everyone’s advice and i wrote a new event referring to it
as advised, i thought it would be better to use the structure and child variables
the result is the picture below.
But I still think something is wrong
Only the value of class.A is reduced, and other values of B, C, and D remain unchanged
Rather, it has been added as a new global variable
I think I’m making a very basic error, but I haven’t found a solution so far, so I’m asking for help again
Your child variables are set to string try changing this to number for instance the letter E is correct but the letter C is a string instead of a number variable type.
There’s a few issues here that I’m seeing:
- Your first event could occur multiple times where it is resetting the random string. You should probably have the “Trigger once” in the first event.
- Why are you using a random string anyway? If you’re just dealing with numbers, why not just do “Change the value of scene variable “RandomA”: Set to ToString(“Result” + RandomInRange(1,5)”. Have your child variables be named “Result1” “Result2” “Result3” etc.
Then your other event is just “Trigger once” “Change the global variable of class[ToString(Variable(RandomA))]: Subtract 5”. You would only need a single event this way, too.
Hi, I’m back.
I think this article is probably the last one on this issue.
First, thank you for the good advice. Based on them, I was able to organize the event and make it simpler.
And the cause of the problem I asked was… very simple. It’s so simple that you might laugh in vain.
It was because of the hiatus. The space thing about space. " " ← This one. I didn’t know that it was recognized as a new global variable because of that one gap.
(Now either of these works well)
Just in case there may be someone who wants to fill out a similar event, so I leave a capture.
Thank you so much for your help!