#how to fix variable not set before reading

52 messages · Page 1 of 1 (latest)

brazen dune
#

############################################################################################
ERROR in
action number 1
of Step Event0
for object obj_player:

Variable obj_player.p1_bomb(100008, -2147483648) not set before reading it.
at gml_Object_obj_player_Step_0 (line 17) - (instance_create_layer( mouse_x, mouse_y, layer, p1_bomb))
############################################################################################
gml_Object_obj_player_Step_0 (line 17)

if anyone knows how to fix this type of error and could break down how to fix it it would be greatly appreciated.

hallow vale
#

What is p1_bomb?

#

I presume it's some kind of object, but it doesn't seem like GameMaker knows an object called p1_bomb

true sandal
brazen dune
#

P1 bomb is an object and I’m attempting to summon it using after clicking the mouse button

#

Does using the prefix obj_ actually change something or is it a suggestion?

hallow vale
#

It's the default recommendation for asset names, as per naming conventions

#

spr_ for sprites

#

rm_ for rooms

#

snd_ or mus_ and sfx_ for sounds

#

Etc

#

Though no one is obligated to follow that pattern

#

I sometimes use par_ for objects that are parent objects

brazen dune
#

I have changed the obj name the code too match the new name,

#

the problem seems too be with the object its self, i have no code on the obj at all now and the problem is still present, I have changed the object that spawns on right click and that works perfectly fine.

#

how do i define an object

hallow vale
#

If the object exists in your project as an asset, then it is already defined

#

Could you share a screenshot of your asset tree with your objects, and the new name of the object you're using?

brazen dune
#

👍🏻

hallow vale
#

Hmm

#

Try adding a create event

#

Anything can be in there, even a comment, or a message

// idk a comment
show_debug_message("Bomb spawned");
brazen dune
#

i added your message to the create event

hallow vale
#

Aha I thought so

#

Your project seems to be looking for a completely different value in the error message

#

Than what you have in your code

#

Which means that very likely the project isn't saving properly

#

By any chance did you rename your project recently?

brazen dune
#

yes

hallow vale
#

How did you rename it

brazen dune
#

and then it started tweakingh

#

uhhhh

#

open project>files>blank game_1> then i renamed the file

hallow vale
#

Yeah don't do that

#

You want to do File -> Save As

#

GameMaker links each file to the main project file, along with it's project name

#

So if you just rename the project file

brazen dune
#

before i changed the naem i saved a copy bc i was worried

hallow vale
#

It won't be properly linked

brazen dune
#

should i just swap to that

hallow vale
#

If the backup isn't too old

#

It's also an option

brazen dune
#

okok

#

thank you so much

#

<#2

#

<3*