• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Use of enums shown as unassigned variables

sv3nxd

Member
Enums can be declared in an unused script and then be used anywhere in the project - just like macros, but for some reason they get shown as unassigned.
Am I doing something wrong?

Script:
GML:
//Script

enum MY_ENUM {
ENTRY1,
ENTRY2,
ENTRY3
}
Any event or place in the project:
GML:
//e.g step event of an object

switch(value) {
    case MY_ENUM.ENTRY1 : //<- Works, but shows as a warning, unassigned
    //something
    break;
 
    case MY_EN ...
 
    .
    .
    .
}
Screenshot:

1586868954715.png

SOLUTION:
Nevermind, I wanted to create an example project to show the behavior, but for some reason I couldn't reproduce the error.
Going back to my other project didn't work either, it was fixed out of the blue.

So apparently retstarting the IDE/changing projects fixes the error.

So I guess for anyone facing this as well: The good ol' "Have you tried turning it off and on again?" should work fine.
 
Last edited:

sv3nxd

Member
Oh, I'm sorry for being unclear.
I was asking for help, I didn't think it was a bug, but rather that I did something wrong.
 
D

Deleted member 45063

Guest
Did you ensure that you have enum ORIENTATION correctly defined/spelled? Also, what happens if you just define that enum above that code block, does it remove the warning then? Furthermore, does running the game still work when you reach that portion of the code?
 

Cpaz

Member
Enums can be declared in an unused script and then be used anywhere in the project - just like macros
Wait- can they really?

Enums are a data type. I'd expect them to have to be defined. I guess it would make sense if that was the case. But even then, the manual makes no mention of this.

But yeah, I'd say try defining it somewhere first. Though, I wouldn't expect an IDE error, but rather a runtime error. So that's strange.
 

GMWolf

aka fel666
If you spelt everything correctly, then it doesn't seem to me like you are doing anything wrong.
Does the game compile?
Do you get the intend behaviour?
If so, then it's probably a bug in the IDE
 

sv3nxd

Member
Did you ensure that you have enum ORIENTATION correctly defined/spelled? Also, what happens if you just define that enum above that code block, does it remove the warning then? Furthermore, does running the game still work when you reach that portion of the code?
Wait- can they really?

Enums are a data type. I'd expect them to have to be defined. I guess it would make sense if that was the case. But even then, the manual makes no mention of this.

But yeah, I'd say try defining it somewhere first. Though, I wouldn't expect an IDE error, but rather a runtime error. So that's strange.
If you spelt everything correctly, then it doesn't seem to me like you are doing anything wrong.
Does the game compile?
Do you get the intend behaviour?
If so, then it's probably a bug in the IDE

Defnining it above my code or in the create event gets rid of the errors, which was to be expected.
Yes, the game compiles without problems and the code works as expected.

Edit:

And yes, it's something I found out when looking into the doc, as it states that they function on a global scale. So I tried out using them like macros.

Then it really just might be bug, strange.
 

sv3nxd

Member
Update:

Nevermind, I wanted to create an example project to show the behavior, but for some reason I couldn't reproduce the error.
Going back to my other project didn't work either, it was fixed out of the blue.

So apparently retstarting the IDE/changing projects fixes the error.

So I guess for anyone facing this as well: The good ol' "Have you tried turning it off and on again?" should work fine.
 

TheouAegis

Member
Wait- can they really?

Enums are a data type. I'd expect them to have to be defined. I guess it would make sense if that was the case. But even then, the manual makes no mention of this.

But yeah, I'd say try defining it somewhere first. Though, I wouldn't expect an IDE error, but rather a runtime error. So that's strange.
Enums are only used by the IDE and compiler to make your own code more readable. They have no meaning outside the IDE.
 
Top