Regex support for variables

Greetings! As the title say, i was wondering if there is any extension or natural support for regex in gdevelop.

Mi intention is that so that players can save their stats and such outside the game since i cant afford a database.

How it would work is that lets say the player inputted “Battle3,Magic1,Bows2”
Thanks to the specified pattern, the game would search for every word and number in between the ,(colons). Therefore, the game shall grab battle 3 and by eventing the game will then turn that into a battle variable equal to 3 for the player, same for magic 1 and bows 2.

If anyone knows if this could be possible i would highly appreciate the help!

1 Like

Not for base variable names, no (not supported in JS either), but if you have a structure or array variable, you could probably use the regular expression extension as needed

Also you could probably just save the structure variable to a json string and export that to a file or the user’s clipboard if you want.

1 Like

Ah so the variable must already exist before the regex can be turned into its value?

All base variables have to already exist, no exceptions. Top line Variables have to be pre-declared. Child variables (structure children or array indexes) can be declared on the fly.

By that do you mean that if i want to achieve what im going for i should either make them child or arrays?

For data structures that are going to change frequently during runtime and may need to be saved or loaded, I generally recommend having a parent ‘gamedata’ structure variable and making all of the needed variables children, yes.