netoxinaa
Member
Hello, I'm new to structs and I came up with this idea of using them for every Menu I have in my game, so each struct menu handles his own variables, text, keys, positioning, etc. In a create event I declared 2 structs, itemMenu and itemOptionMenu. Both of them have almost the same variables and a function "display" which is used to draw the menu and to handle selections. In the step event I added that if a struct variable is true, execute their display function respectively. I want itemMenu to show up first, then if spacebar is pressed, I want itemOptionMenu to show up by changing a variable to true. This spacebar checking is inside the display function of itemMenu. However when I do press it, it pops and error saying "Variable struct.itemOptionMenu(100217, -2147483648) not set before reading it.". I don't know why this happens because both structs are declared in the create event. This is the code:
Create Event
Step Event
I tried declaring itemOptionMenu before itemMenu and using with statement in the spacebar checking but none of them worked. And I couldn't find something relatable in the manual.
Edit: I don't know why in the code activeKeys is in another color, it should be white lol
Create Event
GML:
itemMenu = {
//Some other vars
activeKeys: true,
show : false,
display : function(){
//Drawing the menu and handling selection
if (keySelect)
{
activeKeys = false;
itemOptionMenu.show = true;
itemOptionMenu.activeKeys = true;
}
}
};
itemOptionMenu = {
//Some other vars
activeKeys: false,
show : false,
display : function(){
//Drawing the menu and handling selection
}
};
GML:
if (itemMenu.show) itemMenu.display();
if (itemOptionMenu.show) itemOptionMenu.display();
Edit: I don't know why in the code activeKeys is in another color, it should be white lol