SOLVED Hello. I am getting two errors for my code concerning my options button working.

S

SlFinn

Guest
I have been using Game Maker and GML for a week now. I have been following this YouTube tutorial on how to get the options button to work and show the options list screen.
However, I'm getting these two errors here :

ERROR in
action number 1
of Step Event0
for object obj_options_button:

Variable <unknown_object>.obj_options_button(100091, -2147483648) not set before reading it.
at gml_Object_obj_options_button_Step_0 (line 13) - if(obj_options_button(_click)) {
############################################################################################
gml_Object_obj_options_button_Step_0 (line 13)



ERROR in
action number 1
of Step Event0
for object obj_options_button:

instance_create_layer :: specified layer "Instances" does not exist
at gml_Script_create_list (line 11) - var _list = instance_create_layer(_x, _y, "Instances", obj_List);
############################################################################################
gml_Script_create_list (line 11)
gml_Object_obj_options_button_Step_0 (line 14) - create_list(400, 40, 300, 240, LIST_TYPE.GAME_OPTIONS);


I am not sure how to fix these errors, so i will post my code below to show you what I have done. Please advise me on how to fix any mistakes I have made, or whatever I have left out:

obj_options_button Create Event:

GML:
width = 280;
height = 80;

text = "Options";

hover = 0;

script = -1;
obj-options-button Step Event:

Code:
var _hover = get_hover();
var _click = _hover && mouse_check_button_pressed(mb_left);

hover = lerp(hover, _hover, 0.1);
y = lerp(y, ystart - _hover *8, 0.1);

if(_click && script >= 0) {
    script_execute(script);
}

with(obj_options_button)
{
create_list(400, 40, 300, 240, LIST_TYPE.GAME_OPTIONS);
create_list(400, 320, 300, 280, LIST_TYPE.SETTINGS);
}
Constants script:

Code:
function constants(){

enum LIST_TYPE {
    GAME_OPTIONS,
    SETTINGS
}

enum PR {
    NAME,
    SELECTED,
    VALUES
}
}

My create-list script:

Code:
function create_list(){

var _x = argument[0];
var _y = argument[1];
var _width = argument[2];
var _height = argument[3];
var _type = argument[4];

var _list = instance_create_layer(_x, _y, "Instances", obj_List);

with(_list) {
    width = _width;
    height = _height;
    type = _type;
    
    switch (_type) {
        case LIST_TYPE.GAME_OPTIONS:
        ds_list_add(list, ["Players", 0, [1, 2, 3, 4]]);
        ds_list_add(list, ["Mode", 0, [1, 2]]);
        ds_list_add(list, ["Difficulty", 0, ["Easy", "Medium", "Hard", "Insane"]]);
        ds_list_add(list, ["Close", -1, []]);
        break;
        
    case LIST_TYPE.SETTINGS:
    
    ds_list_add(list, ["Music Volume", 10, ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]]);
    ds_list_add(list, ["SFX Volume", 10, ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]]);
    
    ds_list_add(list, ["Texture Quality", 1, ["Low", "Medium", "High"]]);
    ds_list_add(list, ["Particles", 1, ["Disabled", "Enabled"]]);   
    ds_list_add(list, ["Close", -1, []]);
    
    break;
    
  }
 }
 return _list;
}

I am sorry this is so long but I know you need this information to be able to help me. Please do advise me on what to do to fix these errors. I would very much appreciate it! :)
 

Nidoking

Member
The first error message you posted doesn't match the code you posted. While information is good, correct information is the only information that counts.

The second one says you don't have a layer called "Instances". You need to have that layer or use the name of a layer that exists.
 
Top