Why is this enum reference suddenly broken when using Godot 3.1 alpha3?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alforiumstudios

Hello, everyone!

I’m having an unexpected issue with the latest alpha release (Godot 3.1 alpha 3) and I’d appreciate some input. :slight_smile: Up until now, I’d been able to use enums just like this:

  • Script A (worldmap_grid.gd):
extends TileMap

enum ENTITY_TYPES {PLAYER, NPC, MARGIN, DOOR, DESTRUCTIBLE, INDESTRUCTIBLE, COLLECTIBLE, CHEST, FLAG}

(rest of the script)
  • Script B (which is a child of A):
func _ready():
	grid = get_parent()
	type = grid.DOOR

This used to work fine, up until 3.1 alpha2, but now on alpha3 I get this error message: Invalid get index ‘DOOR’ (on base: ‘TileMap (worldmap_grid.gd)’). Suddenly, the link is broken. I don’t know why this happens. Is it a bug? Has there been a change in GDScript syntax? How do I solve this?

I’d really appreciate any help or ideas in this regard :slight_smile: Thank you!

:bust_in_silhouette: Reply From: SIsilicon

According to a Patreon post,

#23648: Named enums no longer register their values as global constants (breaks compat but prevents annoying name conflicts) – @vnen

Maybe that has something to do with it. Try this instead.

type = grid.ENTITY_TYPES.DOOR

Thank you, that seems to have fixed it!

alforiumstudios | 2018-12-12 22:01