+2 votes

Hello, everyone!

I'm having an unexpected issue with the latest alpha release (Godot 3.1 alpha 3) and I'd appreciate some input. :) 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 :) Thank you!

in Engine by (28 points)

1 Answer

+6 votes
Best answer

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
by (3,910 points)
selected by

Thank you, that seems to have fixed it!

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.