- Thu 15 Jun 2017, 23:18
ToString(Variable(structureDevSaying['text0']))=>My DevSayingText only shows 0. Any idea why?
By using the Variable() expression you get the value as number and by using the ToString() expression you only convert the value to string but not getting the value as string. To get the value as string you need to use the VariableString() expression instead of ToString(Variable()) and you also need to make sure the actual value is stored in a string variable.
Also make sure to add the variable to the scene variables using the editor.
Right click on the scene in project manager -> Modify initial variables
Normally, if a variable doesn't exist GDevelop go ahead and create it for you on request and in most cases it helps to avoid errors with "undefined" variables but not always. In some cases even though GDevelop create the variable on request, it won't work and you get a 0 or an empty string returned as the variable is created, but not being used by the action.
By adding a variable to the list of the scene variables, you can avoid this kind of errors.
Finally, to add an empty string variable to the list, just simply leave the initial value field empty. Make sure there is nothing, not even '' or "" signs. If no initial value assigned to a variable, it is going to be created as string variable.
Also, in case you want to add some text as initial value, you can just simply type the text without using '' or "" signs.