• 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!

Legacy GM ERROR: trying to index a variable which is not an array

S

SwanBon

Guest
Hi everyone,

I am getting this error every time I click on an item (that the player is able to pick up).

control.item [ index , 8 ] refers to a sprite. When the game starts it is defined:

control.item [ index , 8 ] = null_spr

I assume I am doing something wrong to get this error?

___________________________________________
##########################################################################################

FATAL ERROR in
action number 1
of Draw Event
for object item_obj:

trying to index a variable which is not an array
at gml_Object_item_obj_DrawEvent_1 (line 1) - draw_sprite(control.item[index,8],0,x,y)
##########################################################################################

Any help would be great

Thank you
 

Tthecreator

Your Creator!
This alone doesn't quite give us much information.
Some more code could help.
Anyways try to use show_debug_message(control.item) and see what it gives you (this outputs a message to the game maker CompileForm on the bottom of your screen).
Btw I guess control is the name of an controller object. I suggest using prefixes like obj_ o_ O, etc.... for readability. You did add something on the end for your other item_obj, so you should stick to naming schemes.
If control was not intended to be an object, than that's your problem. try removing the "control." part. Although I'm guessing that's not the case since it should have given an error saying that the instance doesn't exist.

Just tell me the result of show_debug_message, just put it before your code in draw event and I'll see if that helps finding your problem
 
Top