Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | zlegacy |
I have a script (Global.gd, loaded as GLOBAL) I autoload with some commonly used enums and constants. For example…
enum TYPES { WEAPON, EQUIPMENT, PLAYER, ENEMY, NPC }
I have a player scene and script. In my player script, I define a constant:
const TYPE = GLOBAL.TYPES.PLAYER
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?
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
.
Ertain | 2018-12-25 06:11