SOLVED problems with fatal error while following the official tutorial :(

S

Sleepy_Maid

Guest
so i was following the third tutorial oficial video about the gml language making a space rock game and doing exactly what she say (i changed just the object and sprite's name but i think there is no problem by doing this, right?) on the part i test if the ship shots the bullets or not the game does not enter and it shows a fatal error screen that says: "
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object obj_cat:

local variable inst(100001, -2147483648) not set before reading it.
at gml_Object_obj_cat_Step_0 (line 14) - inst.direction = image_angle;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_cat_Step_0 (line 14)"
obj_cat is the ship from the game
, aparently it points that part of the problem is the line " inst.direction =image_angle;" could someone help me? im not a native and i dont konw anything aboutprogramming, im completly new, so please be patient :/
 

TsukaYuriko

☄️
Forum Staff
Moderator
Be very careful with the "doing exactly what the tutorial says" - more often than not, the issue is that you are not doing what the tutorial says. ;)

In this case, you did not declare the variable inst before using it. Please show the code where you're using it, as well as the code where you think you're declaring it.
 

FrostyCat

Redemption Seeker
Don't freak out and abdicate the reins to strangers online when you see an error message. It's a tempting emotional reaction when you're new to programming, but nobody gets results in this line of work like that.

Take a step back and read the error message again. It's your making, read it. Really.
local variable inst(100001, -2147483648) not set before reading it.
If you're told that a cake is not baked before frosting it, you would instinctively know that your attempt to frost it is too early because it's still raw batter, and that you should instead bake the cake first. Is it reasonable to blame the frosting for the warning? No, you should have instead blamed your baking procedures.

Now look through that tutorial for places where inst is being set, and once you've found it, compare it letter-for-letter to what you've done. Did you forget punching in that line? Is it in the wrong place (e.g. coming after the line you cited, sealed away behind a conditional statement that might come up false, put in the wrong event)? Did you mistype inst? All of these mistakes would have failed to set inst before your attempt on that line to read it, or accidentally set something else.

If you aren't getting the results that the tutorial author got while others got it right, you must have done something wrong, most likely one or more of the items I cited above.
 

ophelius

Member
Basically, any variable needs to be created/initialized first before you can use them/reference them. Usually the Create event is the best spot to do that because it's done once and only once when the object is first created.

So if I write a line like this:
if(x == 5) game_end();
Gamemaker will look for a variable called x, because I'm asking to compare the variable x with 5, but if it wasn't created first before reaching that line, then the same error you received will occur.

Initializing a variable just means giving it some default value, like 0 or false (x = 0), before the object can use it, as mentioned, usually in the Create event so it can be used in the Step event.
 
Last edited:
S

Sleepy_Maid

Guest
thank you all who replied this post, i really liked it, so... the problem is i am a semi-literate or blind, i probably was sleepy yesterday and did not payed atention to the fact that i did not put the curly braces after the code that decide the direction the bullet goes to, i just left it alone so i failed. thank you but next time ill pay more atention
 
S

Sleepy_Maid

Guest
Be very careful with the "doing exactly what the tutorial says" - more often than not, the issue is that you are not doing what the tutorial says. ;)

In this case, you did not declare the variable inst before using it. Please show the code where you're using it, as well as the code where you think you're declaring it.
yeah, i meant i did not see diferences, sorry and thank u
 

Yal

🐧 *penguin noises*
GMC Elder
It could also be worth pointing out the var keyword. It creates temporary variables, so if you use that to define your variables in the Create event (which is a common mistake since it sounds like the keyword you'd use to define a new variable) they'll be gone in the next event.
 
Top