Hey everybody. Finally got some time to do some coding today. As I'm doing a simple script which gets the keyboard input. It's inside a module and according to keyboard input it sets a enum. My problem is, that the values do work inside the module they get set in but if I want to use the values inside my platformer script/module they don't seem to get updated. I don't get an arror but the keys don't respond either.
Here's the header of the keyboard script:
enum Directions {
Up,
Down,
Left,
Right,
None
};
enum Actions {
Jump,
Action,
Run,
NoAction
};
Directions CurrentDirection;
Actions CurrentAction;
so am I missing something here? Do I need to import or update the values somehow. Because I don't get an error
enums are mainly supposed to replace arbitrary numbers in the parameter list of a function.
If you put "Directions CurrentDirection;" in the header, you're creating one independent int variable for each script.
Put this in the header:
import Directions CurrentDirection;
and this in the main script:
Directions CurrentDirection;
export CurrentDirection;
Note that you can just use "int" instead of "Directions", the point of an enum would be that if you have a function like this:
void SetDirection(Directions dir) {
CurrentDirection = dir;
}
And you type "SetDirection(", the auto-complete window pops up showing Up, Down, etc.
Thanks Khris! That fixed it!