+1 vote

I have a script (Global.gd, loaded as GLOBAL) I autoload with some commonly used enums and constants. For example...


I have a player scene and script. In my player script, I define a constant:


This shows an error below the editor, however, but works perfectly fine in game. The error reads : error (4,1) expected constant expression.

Seeing as how my game seems to work perfectly fine, is there something I am missing or should be concerned with? Is this just a bug or am I really misusing constants and enums together?

in Engine by (15 points)

It could be that, since the PLAYER variable is already global, you don't need to declare it as TYPE = GLOBAL.TYPES.PLAYER; you can just declare it as const var TYPE = PLAYER.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.