#how would you use an unnamed enum?

1 messages · Page 1 of 1 (latest)

undone hemlock
#

in the gdscript docs is this example:

# Enums.
enum {UNIT_NEUTRAL, UNIT_ENEMY, UNIT_ALLY}
enum Named {THING_1, THING_2, ANOTHER_THING = -1}

what is the purpose of the unnamed enum/how would you refer to it to use it?

strange lynx
#

I believe in that case they act more or less like integer constants?
This code works for example:

enum {THING_A, THING_B}

func _ready():
    var my_thing = THING_A
    _do_stuff(my_thing)

func _do_stuff(thing: int):
    print("Thing is %s" % thing)
undone hemlock
#

ah ok so the enum members can be referenced directly

ebon thicket
#

also, if you've got:

class_name Parent
enum {CONST_A, CONST_B}

you can do Parent.CONST_A anywhere

undone hemlock
#

useful, thanks!