New unified variables and variables declaration in GDevelop 5.4

I just said what the founder and the other full-time devs say, so…
And ya I helped many beginners on and offline to get started with GD, years before you were here🙃

Yes they will, because there has been a change. What I said is that there are technical advantages to declaring them. And they are working on making them easier to declare. With just one click on undeclared ones, I think.
But we’ll see, there is a hint and the variable editor button is only 1 centimeter away from the field, 99% will find it on their own. 01
It is normal that years old screenshots may no longer be up-to-date, but that shouldn’t prevent any innovation. Examples and official videos will be updated.

But hey it fully doesn’t matter what I think about it, I didn’t want it too but I don’t think the world is going to end because of that, other changes and the lack of the option to turn it off optionally were more annoying for me.

Sometimes I wish there was more discussion and voting before things are finally implemented, but in the end it is the decision of those who do the work.

2 Likes

I have been using Gdevelop for a long time, and in my particular case, it is a very big job to declare each variable. Added to that, I have many variables with the same name but for scene, object, global, etc. I prefer the previous system (I feel like I have more control over what I do). I really don’t like having to spend a ton of time “fixing” things that aren’t “broken” in my game, with the result being simply the same thing I had before, but I imagine that the idea is not to return to the previous system, so I propose some intermediate to make it easier for those who have larger projects to migrate to the new system. I suggest implementing some quick way to detect all the variables present in a scene (or external event), such as a scan, to be able to declare them with few “clicks”. Also, find out which ones have the same name, to suggest changing them.

I’m interested in understanding this. Would there really be a difference in the performance of Gdevelop games with this system?

Hey there,

I think the new system is a BIG improvement to GDevelop. Here’s why…

Having all the variables declared in the project means having total control over these variables. This links the events with the declared variables so that any change is universally updated anywhere the variables are referenced. Similar to how objects work.

YES it takes few extra seconds to declare each variable.

BUT it eliminates having to type the long expressions and saves a lot of typos in the code. Fixing one simple error in the code can take much more time than the time it takes to declare or edit a variable.

Having the “Freedom” to be able to use undeclared variables made me work the wrong way. It’s a NIGHTMARE to change a variable in a big project with lots of scenes and external events, by going through each events sheet and Search / Replace expressions.

But having this “Limitation” makes for simpler and more streamlined workflow using variables. This forces the use of variables in a more responsible way. Which in the end makes the code easier to read and navigate through, and the project will be more organized.

I had different feelings about this change at first, because I was used to a certain workflow for a long time and the change caught me off guard. And I think a lot of developers are feeling the same way right now.

But after trying the system more and going through the discussions, I understand now the importance of declaring variables and that this is the correct way of doing things!

I’ve been using the engine since GDevelop 4, and I learned a lot and I will continue to learn from the experts in the team and from the community. I also saw how GDevelop evolved since then with every major update.

This variables system is intuitive and will only get better over time. It makes understanding variables simpler, faster and more fun to use.

This is just my opinion and sorry for the long post.

I believe the GDevelop team made the perfect decision!

Many thanks to everyone involved in continuing to make GDevelop more and more awesome!

1 Like

Perhaps. I myself am still not sold on the idea. Possibly because I already listed important variables in their appropriate variable pane so any benefit of doing so now is no more benefit than I had already but with the added ability to take an undeclared variable, say TempVar, and use it as a place to put a json, convert it back into the same TempVar as a structure, erase the structure by turning it to a number etc. I didn’t gain a thing.

Also I liked the long expressions. I made an impressively long expression once when I had first been using GDevelop a few months and I was so proud of its ungainly size I rushed to the forum to share it. I remember Keith I think pointed out that I could have shortened it by doing some of the calculations independently and then using the resulting variables in the expression instead of my verbose and masterful precious.

I am all for people dictating how I do my workflow to make it simpler and more streamlined for them, when they pay me. On my dime, I prefer to do things my way and trust me, when something is quicker and easier I latch on to it because I am lazy and my brain just looks for things like that.

So I for one am pretty disgusted with the change, but it is actually not the first change I have been disgusted with. It really doesn’t matter to me because I love GDevelop and will continue to support it. There is no game engine in the world that is not going to make some change that disgruntles some users but in the end you have to look at majority benefit and the future of the engine. I think they’re being great about the gentle timeline of this whole thing so that people can get migrated over, not just creating a new system and breaking everyone’s old projects outright without ever giving anyone a hint.

I sit on discord trying to solve other ppl problems
Sometimes it is way easier to me to just set up events send screenshot and link to preview of my project to ilustrate+prove it works

This already happened to me but it will be same story for every user for which i try to solve their problem

2 days ago user on discord ask how to make something happen on increments of a number
For sake of simplicity lets say each 5 so at 5,10,15,20,25,30 and so go on

My best idea is to use modulo expression on some variable
(Modulo loops around some number so imagine you have variable seconds and if you mod seconds to 60 then when it should hit 61 it will not go to 61 but instead start counting again from beginning)
So he had variable called Combo
Using compare two numbers condition he could simply go with
mod(Variable(Combo),5)=5
And now in action he could do whatever he wants
And it did not work and it was because my mistake
I forgot module accounts for 0 so when i told him to put there ,5 what it did was go 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 since that’s 5 digits including 0
I did not realize that so i went to test it in my project and show him it is working
And then i found i forgot about that 0
So proper expression would be mod(Variable(Combo),6)=5
Now it would go 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 since that’s 6 digits including 0 and it will hit 5

To do that i needed to declare variable just to test it out in my project in which i do not need that variable
I did say sorry for my mistake and showed him how it should be done

Now i needed to go back to my project and delete manually that declared var which my project won’t use / don’t need
Just so i do not litter my project with random vars

Variable update added me 2 tasks which takes up time if i want to provide that kind of help
There is no argument how long it takes it is few secs to declare and delete vars
BUT each time i gonna help someone this way i gonna need to take 2 additional steps
And i cannot say that my workflow because of this update got better the same way you can
Declaring variable in above scenario did not give me anything and only made me need to delete declared variable in addition to deleting events after i did make visual presentation for someone

And i or any1 here is not asking “please remove declaring variables”
Far from it
Cause you see old system still works so projects using old system do not break
I can copy or pre made variable of each type put it into disabled event group and just copy paste them when i need them
Either way i need now take additional steps each time when i try to solve problem for someone on discord or even here on forums
I won’t die from it but my workflow did not got better

So me or other users are not in need of taking away declaring
We ask for streamlined way declare vars or a easier way to use not declared variables

If new system did make your workflow better then good for you
But consider not all of us do what you do and use gdevelop in same exact way as you do
So for some of us new system can cause more problems than it solves
Where in most cases we did not have problems with old system

I agree with ddabrahim, Lucky-j and ZeroX4 here. Declaring the variables in advance is apparently the best way, but I believe that the user should have the freedom to decide whether they want to do it this or another way, even if the latter is not considered to be ‘good practice’.

It is not only easier for beginners, it also makes it faster to stitch something together for testing or sharing. I see it as a strength that you could do something unoptimized in Gdevelop and it would still run.

Reading through the posts in this topic gave me a flashback to this one 2 years ago, when timers suddenly had to be declared in advance.

Obviously everyone gets used to a new system after spending some time with it, I just don’t believe that those changes make Gdevelop necessarily user-friendlier or faster to use - which is one of the hooks on the webpage to try the engine.

I went into topic you linked i did read all of it
Pure luck but imagine in my games NOWHERE i am using timers
Just because i found out i can use TimeDelta() in vars
Or even go straight up with adding/subtracting some value like 1 or 5
To variables and use that instead of timers
JUST because this way i am not need to start something first
I only add action for it to run and check if value is below or above something and im done
With this method i do not get perfect timing i need to check if something is lasting long enough or not too long for my project
Yet i am able to measure it as i please
To be fair and clear with timers i know how much 3 seconds is
Yet i still need to check if 3 seconds as a cooldown is what i want for my project
Isnt it too much or not enough of a delay
So when i simply go add 1 to variable then check if that variable is above let’s say 100 i do not know how much time it will take for it to get it to 100
But i need to go trough exact same process
Where i do not need to know if 3 secs is enough
I need to know if delay i set is enough or not and adjust it anyway

So in conclusion seems i always avoid methods that required extra steps from me
So it is not about if i start using gdevelop from moment declaring was obligatory i would not have problem with it
I would still look for a way to have easier manage system for my vars

But right now we are running circles
Most of us just try to prove why one system is better over another
And that will prove nothing
I wish we sit and think for a better system for everyone
Throw ideas and eventually we find compromise or a solution that will make everyone happy or at least won’t be penalizing in some scenarios

1 Like

Here is some actual, live, user experience dealing with the variable change.

This is honest feedback, im not trying to trash the new update, its literally just me working and having to deal with this.

I also find pretty quick some issues that need to be adressed, and honestly, amazed that it even works like this in the first place…

Like pressing “Enter” on the variable page just closes the whole thing and dosent save anything… almost feels like im being pranked every time i press it lol

1 Like

just quoting what i said (not here) in this thread for other ppl

but i was thinking …

isn’t possible to restore the old conditions without using the old system…?
i mean

we may restore old conditions just as a “bridge” to declare vars in new system.

eg: if i have a undeclared var in – change the scene variable “my var” set to “1”

it will just bridge to the new system automatically declaring it in the scene properties…a scene var with the same name…so old and new sentences can be used and swapped depending on dev choice
They gonna works as a fake undeclared vars…just miming the old method…
it will just fake you thinking that ure using the old method

It will be just a matter on what you believe to read on the screen

ps : we may even have an option in game properties to see or not the full sentence.
if on it will show the kind of var edited (like old method) Eg: change the “scene” var myvar set to 1.
if not it will show the new sentrence change variable my var set to 1

We all have different experiences and opinions, but one thing we all have in common is that we use GDevelop. A no-code game development engine, and it’s VERY good at it. This change brings GDevelop a step closer to it’s purpose.

The team made this decision for a reason, or many reasons, and they know very well what the advantages / disadvantages are. GDevelop now is lightyears ahead of GDevelop few years ago thanks to the people involved in keeping the engine getting better with every update.

I can say that I know a lot about the engine and I also help people here on the forum. But I’m NOT a GDevelop expert, no way near it actually! I don’t know everything about how the engine works in the background, but there are people who do know. So I learn from them and adjust my workflow to how the engine is designed to work.

Now, we can keep on debating which is a better system, and that this change removed a feature that is supposed to make development faster and added unnecessary friction, or that there are many issues now. But we would be missing the whole point.

For beginners or people getting into the engine, this change makes understanding and working with variables so much easier.

For advanced users, this makes projects more organized, easier to navigate and less prone to errors. Which in return saves a lot of time and effort later.

Variables are one of the most important aspects of development. So if the purpose of using undeclared variables is to prototype and test out ideas faster, then these ideas and prototypes are being built on a more shaky foundation. I prefer spending a little extra time planning and setting up variables to build better prototypes and more solid ideas.

4ian explained it perfectly here:

Sure there are still improvements to be made, and the team is working on them atm. But I found that the new system works pretty well at this stage. Remember that it’s still in its early stages, and with future updates, declaring and editing variables will be much much improved.

You can still use older versions of GDevelop or copy existing older events. But my advice would be to start using this new system from now on.

Take a look on my posts above andv tell me what u think

@RMDB
You see you me or any1 do not need undeclared variables
We just need easier way to declare and remove declared variables
Or to be precise we need better variable management system
Because if your var would be declared on 1st time using it in condition/action
Most arguments in favor for not declaring vars would go away
IF removing all events which include that var would result in var being removed then we are even closer to lose argument in favor of having a way to not declare vars
I do not care if i need or if my var gets declared or not
I care what steps i need to take to properly use variable
Same as to what steps i need to take to not have that var in my project
And in the end if you think about it then that is also all you care about
We could adapt without a problem to new system if it would offer better management options

@insein
No one is arguing here technical benefit of vars being declared
Ppl who are against declaring every var do not want declaring go away
They want only choice between one or another or better system to manage it
IF argument is that when you use var in action engine do not know should it be scene local or global var
Then why not leave 3 buttons in variable window to select them as one or another?
Now engine will know and you are managing your var the moment you start to use it
And you are not need to go to different window to set something up to start using it
By pure logic of newbie
Program wants me to set something 1st before i start using it
Then why it is not letting me do in the window where i am starting to use it?
We are talking about just 3 options here/3 buttons or drop down menu with 3 positions
I am all in for your argument that our projects now get better structured cause we plan our vars and declare them
Yet again if i am just to help you or someone else by preparing some events and making screenshot out of it
Then i need each time declare these variables and delete them later so i do not litter my project
I do not need that variable to be declared if i gonna use it just to show/explain something
Yet with new system i am required to take some additional steps just to be able to do what i was doing before variable update
Declaring/deleting vars do not take hours it takes few secs
Yet i gonna need to do it every single time i want to test something for someone or show how to do something
Where at the same time i can copy existing variable like action/condition
And simply rename it to some undeclared variable and it will still work
So from my standpoint only some actions/conditions for me to using undeclared vars were removed yet i still can use them if i want to
But either way i am forced to make some additional steps
So even if i declare or not declare var and care to use it
I am required to sacrifice more time in doing so than before update

So i say lets think of a better system for declaring lets throw some ideas and see if we can find some solution
Cause right now you can give me 100 reasons why declaring is better and i can give you 100 reasons why having option not to declare vars is better
Yet we will be in same exact situation

But if we start giving ideas how to have better system we will start moving forward

Probably i have not explained well…english isn’t my main languiage…but my suggestion
is to restore the old conditions actions just as fake / bridge sentences.
In game option u can have an option to check if you want to see the full sentence.
eg:

i chose option show full sentence
i chose a condition:
if “scene” variable “myundeclaredvar” is set to 1
GD in background will declare that var in scene variable panel automatically (since it will know the type and the value)…as in the new system.

if full sentence option is unchecked it will show the new sentence
If variable “myundeclared” is set to 1.

variable will be declared in both methods.

Nah i do get you
But
1 - we are regressing from having 1 action/condition to having multiple
Where on other hand we still have separate for object and other vars
2 - I say having one action/condition is still less confusing for new users

That is why i offered option where in same exact window we change variable in action or check variable in condition we do all the choices

You do not need to look for other options since all options you could possibly want to select/choose are right there in your face

Look at it this way
You do not need to look for proper option on the left list
You can click whatever you want on the right side of window and see what will show up is it what you want and i say you have better view over what you did select

Maybe i am biased cause its my idea
But what i offer could work as you describe just without 3 separate actions/conditions on the left side of the window

And now let’s look at it this way
I do not want to declare variables
How many times i gonna set up these options before i start declaring them? So i do not need to set up these options over and over?
Yet if i am using var just to show something who needs help i can choose to not declare var and it will not be added to the list and so for purpose of that i can set up few options where in most cases i will just leave it with default values like number scene var and all i input is name and what i would normally select which is sign/operator and value

The problem is that they don’t want undeclared vars anymore…(for whatever reason).
with what i said above there are no undeclared anymore… but you can still write a sentence withot the needs to go in the panel or pop ups tho chose things

Because let’s face it they are right
We do not need undeclared vars
All we need is easier system to declare and remove declared vas
So how about let’s go other way around
Let’s go with auto declare when you use var
Yet you have option there to tag this var as temp var
Meaning that if all events for this var are deleted then var no longer exist in your project
It would be declared but as soon as you tagged it as Temporary var (there would be button for that) it would special icon to notify you its temp var for example some clock icon or whatever
You delete all actions/conditions including this var then it gets deleted from the list
Wouldn’t that be a solution?

Thaz indeed my suggestion…
but i don’t get you…wha’t the needs of a temporary var if it will be deleted anyway (even form the panel) when theare are no sentences?
prolly i have not understand well

Look do you really need undeclared variables
Or in some cases declaring variables just do not make sense?
Cause i say we do not care for being able not to declare vars
We care to just use them so who cares if they get declared or not?
So instead of opting in for not declaring them let’s opt in for auto declaring variables when using them which of course would involve more options in action/condition window
Yet if for whatever reason you do not need that variable in your list you just need it for a moment to show something with screenshot
You tag it as temp variable (you simply press button in that action/condition window) so after you delete all events with that var it gets delete from your project meaning it is not declared anymore

If that would pass i would question any need for variables to be not declared since i would find no use for them
Where key word here is auto declare
Process should be automated and then all arguments for them being not declared would go away
Or am i wrong?

1 Like

Right thaz what i said :smile:
i’m ok too for a temp tag if all sentences are removed
:handshake:

to sum up:

let’s just use old conditions action as a tool/option to autodeclare all vars in the new system

1 Like

btw as i was giving this a try i figured out why you cant have same name variables in Scene / Global and so on… its for expressions.

They removed the need to type Variable(myVariable) and GlobalVariable(myVariable), now you just type “myVariable”, and since you cant have multiples, the system knows if its a Scene, Global whatever…

This seems way better and quicker if it wasent for a few snags…

If you try to plan ahead and organize your variables in structures, you still get the mouth full of Structure.myVariable, if you plan ahead for saving all your variables to do a save system and put your variables into a single structure with structures in side to be organized, you still get Scene.Structure.myVariable

Which would kinda be ok, but now you have extra cliques, and i dont mean for declaring…

Before, you could type in an expression “Variable(myVariable)” and hit “Enter” to close the whole thing and move on, now you cant, pressing enter auto completes but dosent give you the “dots” or even close the prompt if your finished, you have to clique off which i find personally annoying.