• 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 RPG Inventory System

N

NthingSinistr

Guest
So I have this inventory system that draws based on the view, and is toggle able. The problem comes when I regenerate the room and then toggle the inventory, and I get this error:

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Draw Event
for object obj_inventory:

Unable to find any instance for object index '102361'
at gml_Object_obj_inventory_DrawEvent_1 (line 38) - button.x = ix;
############################################################################################

Here's the code.



Event: obj_inventory_Draw_1:

Code:
if (showInv)
{
    var x1,x2,y1,y2;
    x1 = view_xview[0] + 1464;
    x2 = x1 + view_wview[0] - 1440;
    y1 = view_yview[0];
    y2 = y1 + 1080;

    draw_set_color(c_black);
    draw_set_alpha(0.8);
    draw_rectangle(x1,y1,x2,y2,0);
    draw_set_alpha(1);
  
    for (i = 0; i < maxItems; i += 1)
    {
        var ix = x1+48+(i * 40);
        var iy = y2-368;      
        
        if (i >= 10 && i <= 20)
        {
            ix = x1-352+(i * 40);
            iy = y2-326;
        }
      
        if (i >= 20 && i <= 30)
        {
            ix = x1-752+(i * 40);
            iy = y2-285;
        }
      
        if (i >= 30 && i <= 40)
        {
            ix = x1-1152+(i * 40);
            iy = y2-244;
        }
      
        draw_sprite(spr_border,0,ix,iy)
        button[i].x = ix;
        button[i].y = iy;
    }
}

Event: obj_inventory_press E-key_1:


Code:
if showInv = false
{
    showInv = true;
}
else
{
    showInv = false;
}
 
N

Ninjai

Guest
Go through all your functional objects related to the inventory and make sure they are all checked as persistent. The same thing happened to me one night when I was overly tired playing around with code and just closed out of stuff rather than save. If these objects aren't persistent they won't carry over to every room and the code you posted requires them to.
 
Top