GameMaker Unable to find instance for object

ERROR:
Unable to find any instance for object index '121' name 'fc_content_s1'
at gml_Object_flipCombo_Step_0 (line 37) - if (slot_1 == fc_content_s1.fc_content_is) { slot_check_1 = true; }
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_flipCombo_Step_0 (line 37)

So the puzzle works great (and this error doesnt pop up) when I have puzzleActive set to true, allowing the puzzle to be on screen and workable. But when I set it to false so i can test it popping up i get this error. Here is the code...

Create:
Code:
puzzleActive = false;
puzzle_fcWinner = false;

view_w2 = room_width * 0.5;
view_h2 = room_height * 0.5;

image_xscale = 2;
image_yscale = 2;

fc_cs1 = fc_content_s1;
fc_cs2 = fc_content_s2;
fc_cs3 = fc_content_s3;
fc_cs4 = fc_content_s4;
fc_cs5 = fc_content_s5;

slot_check_1 = false;
slot_check_2 = false;
slot_check_3 = false;
slot_check_4 = false;
slot_check_5 = false;

boxColor    = c_black;
_time        = 0;
_start        = 0;
_end        = .5;
_duration    = 60;
Step:
Code:
#region Puzzle

if (puzzleActive) {
    
    x = view_w2;
    y = view_h2;
    
    instance_create_layer(x, y-110, "PuzzleTop", fc_selector);
    
    instance_create_layer(x-132, y+117, "PuzzleTop", fc_btnLeft);
    instance_create_layer(fc_btnLeft.x + 86, fc_btnLeft.y, "PuzzleTop", fc_btnRight);
    instance_create_layer(fc_btnRight.x + 86, fc_btnLeft.y, "PuzzleTop", fc_btnUp);
    instance_create_layer(fc_btnUp.x + 86, fc_btnLeft.y, "PuzzleTop", fc_btnDown);
    
    instance_create_layer(x-217, y, "PuzzleTop", fc_content_s1);
    instance_create_layer(x-108, y, "PuzzleTop", fc_content_s2);
    instance_create_layer(x, y,        "PuzzleTop", fc_content_s3);
    instance_create_layer(x+108, y, "PuzzleTop", fc_content_s4);
    instance_create_layer(x+217, y, "PuzzleTop", fc_content_s5);
    
    puzzleActive = false;
    
}

#endregion

#region Solve

if    (slot_check_1) and
    (slot_check_2) and
    (slot_check_3) and
    (slot_check_4) and
    (slot_check_5) {
        puzzle_fcWinner = true;
}

if (slot_1 == fc_content_s1.fc_content_is) { slot_check_1 = true; }
if (slot_2 == fc_content_s2.fc_content_is) { slot_check_2 = true; }
if (slot_3 == fc_content_s3.fc_content_is) { slot_check_3 = true; }
if (slot_4 == fc_content_s4.fc_content_is) { slot_check_4 = true; }
if (slot_5 == fc_content_s5.fc_content_is) { slot_check_5 = true; }

#endregion
Variable definitions:
 

TheouAegis

Member
Well yeah, because you only create instances of those objects when puzzleActive is true. You can't expect to read variables from instances if you never create them in the first place. You can check if fc_content_s1 exists before trying to read any of the variables, but the fact still remains that you told your code to try to read from non-existent instances.
 
Well yeah, because you only create instances of those objects when puzzleActive is true. You can't expect to read variables from instances if you never create them in the first place. You can check if fc_content_s1 exists before trying to read any of the variables, but the fact still remains that you told your code to try to read from non-existent instances.
oh, well duh. Geez. Is it that obvious that im new. lol
 
Top