Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

probably something I am overlooking but I added a new player and then added a new button instance in the player select room but when I go into the room I get this error 

ERROR in

action number 1

of Other Event: User Defined 0

for object obj_keyboardmenucontroller:

Variable obj_playerselectbutton.menugridpos_x(100297, -2147483648) not set before reading it.

 at gml_Object_obj_keyboardmenucontroller_Other_10 (line 3) -        if(menugridpos_x == other.menugridpos_x && menugridpos_y == other.menugridpos_y){

############################################################################################

gml_Object_obj_keyboardmenucontroller_Other_10 (line 3)

gml_Object_obj_keyboardmenucontroller_Create_0 (line 18)


still kinda new to GM

(1 edit) (+1)

It's probably the order the Create Events run. The new button gets added at the end of the list, so it's not finished setting up when the keyboard menu controller's Create Event runs (it finds the currently hovered menu button by checking their "menu grid position" variables - but they don't exist until after the button objects have been properly created). You need to open the room's "Instance Creation Order" (there's a button in the inspector) and reorder things so the controller is created after all the buttons:


(There's a comment about having to do this in the create event of that object, but I maybe should've put it somewhere more visible...)

(+2)

Actually, I just realized there's an even better way to solve it - moving the "event_user(0)" from the Create event to the Room Start event (which runs after all create events have finished), that removes the creation order dependency entirely! Just cut and paste it into the indicated location:

I'll update the base download with this change as well so more people can avoid suffering.

(+1)

Ah your a lifesaver thanks