GlobalVariableString() is returning '0' when a String variable is empty
Hi all,
I think I found a bug when using GlobalVariableString(variableName) function.


When the value of the String Variable is empty, the Preview renders a '0'.
This is because this line in Runtime/variable.ts:
} else if (this._type === 'string') {
this._str = '' + varData.value || '0';
}
If varData.value is empty, then this results as '0':
this._str = '' + '' || '0' -->
this._str = '0'

In the same Runtime/variable.ts, you can see that the method setString(newValue: string): void doesn't use these || '0' at the end, so I think it should be equals both the constructor and the setString().
setString(newValue: string): void {
this._type = 'string';
this._str = '' + newValue;
}
I attach 2 videos Before and After the fix.
Please, check if I have missed something important. Thanks in advance!
Before the fix
https://user-images.githubusercontent.com/21989259/213698045-604a55ad-7d68-42b3-8d52-d3ee80bf6c79.mp4
After the fix
https://user-images.githubusercontent.com/21989259/213698074-ddf61a8e-7d83-4dcb-924f-c99a06235d83.mp4
🤔 We need to be very careful with this, since "0" has been GDevelop's default value for string variables for years, and many events sheets rely on this assumption to know whether or not a string variable is defined. Here, this may be fine since this only applies to per-declared strings, and we may want a string defined as "" to be indeed empty... Although, that still remains a breaking change of a core feature of GDevelop.
Let's handle this with the utmost care.
This came back up again from a few users (and myself) as unexpected behavior. https://github.com/4ian/GDevelop/issues/7267
@arthuro555 with the variable feclaration changes, and this behavior being different from how dynamically created structure/array children strings are handled, is this something that can be updated more easily now?