I propose a new section next to “Global Variables” called “String Tokens”. This would be a catalog of key/value pairs where the keys are token names (probably restricted by object naming constraints) and the values are Strings.
Then anywhere in a GDevelop field that expects a String value you can “$TOKEN_NAME” (with auto-completion once you start typing after the $… and also warn if no token by the current name is defined) and at compile/preview/runtime it will substitute in the string value for that token.
These tokens should be backed by a simple JSON file, and a new action should be added that allows reading tokens from a JSON file which would override any existing tokens with the same name.
Here are some of the benefits this offers to GDevelop users:
- Less typo errors when using static strings (i.e. GameState = “idle” vs “Idle”)
- Create translation catalogs! (Text is defined using tokens, and you can load different language values using specific JSON)
- Macros? (Depending on when the substitution is done it could be possible to take commonly used complicated Strings like “PlayerState[GlobalVariableString(CurrentState)].Stats.Health” into a token like $PLAYER_HEALTH)
I know this is a little more low-level than GDevelop typically goes, but it could really help reduce errors and allow for a lot more abstration.