Scene variables are useless now?

Actually scene variables used to be very useful and they were kinda replacing the local variables, cause it was possible to declare scene variables in event sheet and not be bothered with redeclaring of the scene variables in another scene (if you needed to).
But now scene variables seem to be useless, cause now there are local variables and it seems like they can be used for purposes scene variables are used (local variables can be declared in event sheet directly and there’s no needs to declare them again in other scenes).
What do you think?:thinking: Are scene variables still useful or this feature should be get out the engine for clean variables list at least?

Scene variables values are saved between frames
Local variables exist only on that exact frame on which they are declared via events

For example if i declare in variable window variable called Score and set it to 100

Then i can ANYWHERE in events sheet change text of text object to Score and it will display 100

If i declare local variable as Power and set it to 200
BUT i gonna put it on very end of my events sheet then NOTHING above that even can use that variable
Only what is sub event to even with local variables can use it

And on top of that
If i again declare that variable Power and set it to 200
In event below it i gonna subtract 15 from it and we now have 185
Then ANYTHING above that event which can read that variable will still read 200 cause subtraction happened below it and anything above is reading its declared value which is 200

Think of it like we sit next to river

If water flow goes right like arrow shows
Then whatever B throw into river like it can be toxic waste or gold
A will never be able to see cause it happened AFTER A
Only what A will throw into river can be seen by B
And it will not loop like with scene variables

2 Likes

Yeah, i get it, local variables don’t work everywhere in event sheet, but global variables do. So again my main point is scene variables were replacing local variables with ability to declare them directly in the event sheet, but now there are local variables and you can use them and you can also use global variables,so there’s no need in scene variables anymore

Still no
Global variables exist between scenes
So if you reload scene like change scene to death scene and go back to game scene you would need to reset every single global variable
Like HP score and whatever elese

If you would use local vars then you would need to have on top event which declare them and everything that use any variable need to be sub event to it
Imagine having 50 variables how much of event sheet declaring them in events sheet it would take
And then we are back to initial problem
Where local variables are not preserved between frames

Even something as simple as how many enemies you killed in some level and imagine you have 10 types of enemies and you want to track how many of them you killed in SOME level while being in that level

With global variables it would mean you need to have event
At beginning of scene set these 10 variables to 0
With local you would not be able to track it
With scene you could just reset scene to set them back to 0

I know what you are trying to say but trust me there is very justify reason we still have scene vars

Ok, get your point of view🙂 Just thought about it recently after using Gdevelop 5.3 which had the old variables system, and i realized how the old system was usable and simple so now i use this version of Gdevelop. I mean the simplicity like “declare variable wherever you want and just access through name of it” is smth I’d keep in Gdevelop

You still can
Make scene variable set it to structure and call it Z

Now you can anywhere in events change variable Z[“WHATEVER YOU WANNNA NAME IT”]
To anything

For example
image

I only declared Z
I can on the fly type there name of ANYTHING i want and it will just work
Only requirement is to have that structure variable
And we are back to previous variable system without declaring

The older version of GDevelop allowed you to reference a variable that didn’t exist and GDevelop would create it for you. That’s been tightened, so you need to declare the scene variable before it is used. It’s not that it was simpler before - it’s that now it reduces laziness and potential errors.

What kind of variable you should use depends on its purpose and scope - entire project, a specific scene, a subset of events or the lifetime of a scene object.

3 Likes

Each project is different. Everyone has their own style.

If you had multiple scenes that were similar, you could use only local and global variables. If the scenes were dissimilar then you’d probably want to use a mix of scene and global variables. That way the scene variable lists would reflect the variables in each scene and it would keep the lists from being too cluttered.

They’re using local variables for loop counters. That’s a feature that I really love. It’s pretty close to a For… Next function.

In the end. I think it comes down to personal preferences. Keeping all types of variables doesn’t interfere with any style.

2 Likes

I don’t think so, man🥱. Because it was simpler and it was not about laziness, it was actually useful. And you said about errors, which doesn’t mean it was a bad approach, but it means it was an unpolished system👻.
I just find the old system pretty usable. And as i said i use old version of Gdevelop because of that approach :smiley_cat:

That’s not a bad approach, that’s devs getting away with laziness because the variables weren’t strongly typed. Until it failed because devs were using the same variable name for different usages and then wondering why it had the wrong data in it and the game acted weirdly. Or why a structure had more children than it should have and caused issues when iterating over them. It happened more often than it should have.

But you do what you’re happy with. If the older system suits the way you want to code, then go for it.

And Ronnie O’Sullivan’s still using the old chalk!!

(at the Snooker World Championship)

All the other pros are using the new chalk ….as there’s no unexpected kicks from the cue ball, and unexpected bounces off the cushions, and no nasty chalk marks on the table!

But Ronnie O’Sullivan knows what I likes, and he likes what he knows! And Ronnie likes the old chalk!!

It irritates some of the other ……and Ronnie, I think, takes some satisfaction from this.

Back to GDevelop ……today I’m using it, and instantly it adds ToString() when im putting a number expression in the change text to bit ….I didn’t ask it to! Just did it BAM!! Don’t remember it ever doing it before!

Ronnie O’Sullivan regards this sort of thing as hand holding! Exactly the sort of thing that he doesn’t want happening while playing snooker!! I don’t know where I’m going with this now, but……Alex Higgins and …sorry not Alex, he’s dead …the other one …John Higgins!! And Neil Robertson go up to Ronnie after frame 8, holding hands. ‘But we like hand holding!’ They announce together!! In unison!!

Ronnie ……shows them both his long forefinger, pulls out the old chalk, and rotates it around the tip. He reaches forward, with a steely look in his eyes and draws with the chalk across John’s silky black waist coat the words….

‘Scene Variables Are Useless!’

Right…sorry I get back to what I was supposed to be doing now

You are missing the point
We both can buy matches but that does not mean we need or want them to use for same purpose in same way
For example i buy matches to glue stuff with super glue
As kind of one time stick which i use to paint glue over stuff

For most ppl matches are for setting up something on fire

As a side note
I am using GIMP from 2013 yeah 13 years old version

Cause it have hue-saturation as tool
Any version above it have it as effect
So when i want to replace all red colors to green on my canvas
I can click that tool and bam

Any newer version have it under menu on top
Tools > color > hue saturation

Yeah not buried deep but still its way faster for me to click it from tools list than go trough drop down/cascade menu
And that is why i did not upgrade

Cause everything in this version works for me and i can create in it whatever i need
I won’t upgrade for sake of being up to date when something that crucial to me that i use constantly would get buried under menus

We could sit here whole day and you could try convince me to update GIMP
But unless you gonna give me option for that tool to be in tools list
I never will

You will never win with ppl habits

2 Likes

The old system also required you to put Variable() or VariableString() every time, so if you’re OK with that then it should be no problem to use ZeroX4’s method. Just make a structure called “vars” and it is essentially the same. Meanwhile, you won’t be stuck on an outdated version of the platform…

In version I currently use there’s already access to variables with their names so it’s not applied to my situation

Just to be clear: There is no version of GDevelop that you can use variables that arent predefined in an expression/steing without using the scope expressions (GlobalVariable/Variable/Object.Variable())if you are using the old system you will have to use these types expressions in longer expressions or strings. It’s totally fine if thay version is what you wish to use I’m just adding clarity to what was mentioned above.

It’s also important to note that old releases of GD5 are not supported at all, so you’ll be on your own for questions on event structure, error messages, or other issues. Similarly, there is a chance the online build service may have requirements changes on the backend, which you wouldn’t get the updates for either and would no longer be able to do one-click builds and have to do builds locally.

Again, All of this is just so you are aware what using an old engine version entails. You are welcome to do so if it better suits your needs, however.

I’m aware that there could be a problem with online exports in old version, and that’s the exact reason why i learnt how to export projects manually with the help of node js and cordova, so that’s not a big deal for me anymore :gear:

1 Like