0 votes

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?

asked Dec 24, 2018 in Engine by zlegacy (12 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 How to use this Q&A? before posting your first questions.