As me and the boys recently learned, the expression editor displays both versions of the object variable expression (Object.Variable(x)
and Object.VariableString(x)
), however both are named "Object Variable"
as opposed to "Text of an Object Variable"
/ "Value of an Object Variable"
. Please refer to this post:
Why don’t object variables, when used in expressions, have separate ‘value’ and ‘string’ versions?
[image]
Global and scene variables do:
[image]
Using a string object variable in this way results in: ToString(OBJECT.Variable(VARIABLE)). Whereas using a string scene variable with ‘Text of a scene variable’ results in: VariableString(VARIABLE).
So without typing it manually, is there no way to get OBJECT.VariableString(VARIABLE)?
1 Like
Update: OP BWPanda recently filed a report on the github regarding the same issue:
opened 12:52AM - 25 Aug 22 UTC
## Describe the bug
When using the Expression Editor to add an object variable … to your expression, only one option shows up:
![image](https://user-images.githubusercontent.com/2385329/186548882-c1d0fbd8-76f3-4aa3-904d-2b27cab93663.png)
Whereas I'd expect there to be two options (one for strings and one for numbers (values)), just like for scene and global variables:
![image](https://user-images.githubusercontent.com/2385329/186549000-59788fc3-354c-49f6-839b-ba337ec52ad7.png)
This is confirmed by the fact that two separate object variables are listed when you do a search, it's just that both have the same name:
![image](https://user-images.githubusercontent.com/2385329/186549134-3333eaf8-19b2-4fa1-bd85-968f57da3b18.png)
The problem appears to be here, where both object variable expressions have the same name, so one must override the other:
https://github.com/4ian/GDevelop/blob/master/Core/GDCore/Extensions/Builtin/BaseObjectExtension.cpp#L1100-L1122
```
obj.AddExpression("Variable",
_("Object variable"),
_("Value of an object variable"),
_("Variables"),
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"));
...
obj.AddStrExpression("VariableString",
_("Object variable"),
_("Text of an object variable"),
_("Variables"),
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"));
```
See https://forum.gdevelop.io/t/object-variables-dont-have-value-string-versions/41744/4 for where this was discovered.