GML referenced once their nothing to referenced

sadsack

Member
I don't understand this I have an if statement with nothing in it and I am still getting only referenced once.

GML:
if (keyboard_check_press(ord("Q")))
{
        
}
here is what it looks like



I don't see what what I am missing
Thank you
for any help
Renny
 

Attachments

rytan451

Member
That's because there's no built-in function keyboard_check_press. You might be thinking of keyboard_check_pressed instead.
 
There is a specific colour that the text of any function will be and that colour is different to the colour of a variable. On top of that, for all built-in functions native to GMS you can middle-click them and it will take you to the manual page of that function. If you middle-click a variable it does nothing. Make sure to start building the habit of paying close attention to small details like this when you are coding, computers are very precise and require exactitude to function, any small error will throw them off.
 

sadsack

Member
I guess I don/t understand what referenced once error is.

I have this in the create event

GML:
///Inititalize variables

//list of guns used in the game


enum gun
{
     pistol,
     rifle,
     shorgun,
}

equipped = gun.rifle;
primary = gun.pistol;
secondary = gun.rifle
and I have this in the step event


Code:
if (keyboard_check_pressed(ord("Q")))
{
    if(equipped == primary)
       equipped = secondary;
    else
       equipped = primary;
}

//shootand make bullet
if(mouse_check_button_pressed(mb_left))
{
    if(equipped == gun.rifle)
     {             
        instance_create(x, y, obj_bullet)////////referenced once.
     }             
    else
      {           
        instance_create(x, y, obj_pistol_bullet)//////referenced once.
      }           
}
You can see that both of my instance_create have /referenced once errors.
I do have both objects .

Where else should the objects be referenced

I am at a lost on this.

Renny
 
instance_create_layer or instance_create_depth
The Manual and Autocomplete are your friends.

Referenced once means the variable is not used anywhere else in the code.
 
Yes, referenced once means the computer thinks that you are using a variable that you have created. If you name a function wrong, the computer creates whatever wrong thing you have typed as a variable, and since that variable is only ever being accessed once (at the moment of creation), it sends you a warning, specifically to point out "maybe you mispelt this or something, but you don't use this variable you created anywhere else in your code".
 

sadsack

Member
I found out that you have to use this " instance_create_layer(x, y, "instance_1", obj_bullet);"
I get this run time error
instance_create_layer :: specified layer "instance_1" does not exist
at gml_Object_obj_hero_Step_0 (line 76) - instance_create_layer(x, y, "instance_1", obj_bullet);
############################################################################################
gml_Object_obj_hero_Step_0 (line 76)

I do have that layer
I am using the newest GNS2 and this tutorial is old. That may be one of my problems.

Thanks RefresherTowel for the tip on the middle mouse button
Their is another function called instance_create_depth ( ) . I used that and it worked ok
thanks for the help

I am still not done with this part yet.
May be back
Thanks all
Renny
 
I am using the newest GNS2 and this tutorial is old.
This is indeed a bad idea, you should really focus only on 2.3+ tutorials until you have a good grasp of what you are doing, otherwise, you will have no idea if an error is because 2.3+ is just different or if it is because you are incorrectly following the tutorial.
 

sadsack

Member
That is what I plan to do after I get this one done. I all ready have many hours into it. You are so right that the next tutorial I do
will be a 2.3 one.
Thank you for your time
Renny
 
Top