Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement global variables #88320

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

groud
Copy link
Member

@groud groud commented Feb 14, 2024

Sooo, this is a draft PR trying to implement this: godotengine/godot-proposals#5832

For now, I'd rather limit the time I spend on it. My plan was to implement a first version without typing (as creating an editor capable of selecting a type, including scripts/classnamed objects, is a complex task).

For now it's not working properly. I think the only thing missing is likely at the "gdscript compilation" level, as I need to be able to assign the constant a value. However, the parser/analyser seems to be working fine, and does not spit any error when seing the new variable. However, at runtime, I get either errors or the singleton does not get assigned.

I'm just opening this PR to discuss if the implementation looks like going in the right direction, and if it is a desired feature of course (I like it a lot, having non-node and non-constant global variables is quite practical)

@groud groud changed the title Separates singletons from autoloads Implement global variables Feb 14, 2024
@AThousandShips AThousandShips added this to the 4.x milestone Feb 14, 2024
@aaronfranke
Copy link
Member

having non-node and non-constant global variables

Note that you can also do static var, which is scoped to the class like const but can be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants