• 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] My inventory stopped drawing and I'm unsure why.

Alex.

Member
I've been trying to get help for this for a while now. So there's that.

I've been following this tutorial (but with some things removed to fit what I wanted). I finished the second part and decided to mess around a bit by changing the
Code:
inv_slots = 15;
to "inv_slots = 10" but then it broke; the inventory menu/gui didn't draw. It's set to where it draws when you open the game so pressing "I", the button you use to open the inventory, wouldn't matter. But even when I press "I", it doesn't work.

The only other thing I can currently remember doing was adding
Code:
randomize();
to make the items random each time (as the items are currently randomized because that's what was called for in the tutorial for testing?). If I remember anything else, I'll be sure to add.

Here are some bits of the coding I think could be relevant:
Code:
///getting the inventory on screen.
depth = -1;
scale = 1;
show_inventory = true;

inv_slots = 15
inv_slots_width = 5;
inv_slots_height = 3;

Code:
if(!show_inventory) exit;

/// inventory back
draw_sprite_part_ext(
    spr_inv_UI, 0, cell_size, 0, inv_UI_width, inv_UI_height, 
    inv_UI_x, inv_UI_y, scale, scale, c_white, 1
    );

Code:
/// i = open up the inventory.
//if(keyboard_check_pressed(ord("I"))) { show_inventory = !show_inventory };
if(keyboard_check_pressed(ord("I"))) { show_inventory = !show_inventory };

/// r = reset
if(keyboard_check_pressed(ord("R"))) { game_restart() };

/// r = close game
if(keyboard_check_pressed(ord("P"))) { game_end() };

if(!show_inventory) exit;

While looking around, the only theory that came to mind was "perhaps I accidentally removed an "if(!show_inventory) exit;" but that didn't work. I also had the debug(ger?) redirect me to my player object's Step Event which doesn't have anything to do with anything and was working perfectly well. (It did give me the chance to change the controls from arrow keys to WASD lol) And to be honest, I'm not sure how I could even fix this in general? What do I Google? I looked for anything off in the code and checked the comments section. No luck. (I'm also new to GML and coding in general so...there's that)
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Make sure that the inventory draw variables are what you think they are and also make sure you haven't accidentally made the inventory object invisible in the Object Editor.
 

Alex.

Member
Oh, the invisibility seemed to be the problem. I made it invisible because I thought that the sprite itself would be invisible or something if I gave it a sprite...? Looking back, my logic makes no sense lol.

Thanks. :0 New thing to look for now lol.
 
Top