• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Fatal Error problem

Status
Not open for further replies.
G

gohkenytp

Guest
Can somebody tell me what this means:

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.oposite(100165, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 3) - if oposite = 1
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 3)

Please help MEEE!!!!!
 

Sabnock

Member
It means that you have not given the variable opposite any value before trying to read from it.

Does it have an initial value set in the create event or is it set by code elsewhere? Either way GMS needs the variable to be set before it can read it.
 
Last edited:
G

gohkenytp

Guest
I tried "opposite", but still comes up. Take a look:

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.opposite(100165, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 3) - if opposite = 1
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 3)

I tried "opposite", but still comes up. Take a look:

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.opposite(100165, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 3) - if opposite = 1
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 3)


HELP ME PLEAAAAAAAAAAAASSSEEE!!!!!!
 
Last edited by a moderator:
G

gohkenytp

Guest
I setted opposite, but that still happens:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.opposite(100165, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 3) - if opposite = 1
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 3)
 

chamaeleon

Member
I setted opposite, but that still happens:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.opposite(100165, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 3) - if opposite = 1
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 3)
It (the instance variable opposite on an instance of object type obj_drawbridge) is not set, because you keep getting the error. Post code showing where it is set.
 
G

gohkenytp

Guest
It's set right here:
image_speed = 0
if opposite = 1
{
if global.drawbridge = 1
{
solid = 0
sprite_index = 0
}
else
{
sprite_index = 1
solid = 1
}
}
else
{
sprite_index = global.drawbridge
if global.drawbridge = 0
solid = 0
else
solid = 1
}
 

chamaeleon

Member
It's set right here:
GML:
image_speed = 0
if opposite = 1
{
    if global.drawbridge = 1
    {
        solid = 0
        sprite_index = 0
    }
    else
    {
        sprite_index = 1
        solid = 1
    }
}
else
{
    sprite_index = global.drawbridge
    if global.drawbridge = 0
        solid = 0
    else
        solid = 1
}
No, it isn't. You are just using it to compare it to the value 1. It has not been set yet with any value (0, 1, or anything else) that can be compared with 1.
 
G

gohkenytp

Guest
I don't know how to do it! Besdies it keeps getting that fatal error.
 

ophelius

Member
You need more understanding in how variables work first. If you can't understand what is happening here and want people to fix it, then you'll never learn and get better.
Read through this document:
 
G

gohkenytp

Guest
Look, I'm trying to make a SMB3 drawbridge but it keeps getting a fatal error. That's it!
 

ophelius

Member
Look, I'm trying to make a SMB3 drawbridge but it keeps getting a fatal error. That's it!
People are trying to help you, they say and I'm saying that you NEED to first declare any variable by giving it some initial value BEFORE you can use it in an if statement or wherever. Typically variables are first always declared in the Create routine of an object. Make sure you have opposite = 0 in your create routine before any other uses of that variable. GM would then set that variable in memory and you can use it normally.
 
G

gohkenytp

Guest
Make sure you have opposite = 0 in your create routine before any other uses of that variable. GM would then set that variable in memory and you can use it normally.
I tried that, but it still keeps getting the fatal error:

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.oposite(100168, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 2) - if oposite = 0
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 2)
 

ophelius

Member
I tried that, but it still keeps getting the fatal error:

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.oposite(100168, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 2) - if oposite = 0
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 2)
Look at the error and how it's spelled, it's referring to a variable called 'oposite' but your code says 'if opposite = 1'
 
G

gohkenytp

Guest
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.oposite(100168, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 2) - if opposite = 1
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 2)

Did you actually get it now?
 

Nidoking

Member
Which language are you Google Translating from? Maybe someone here can phrase it in a way you can understand in your native language.
 

ophelius

Member
I'm not sure what you mean by "Did I actually get it now?", but I know and understand that error very well, and all I know is the error is telling you it's accessing a variable called 'oposite' in your drawbridge object create routine at line 2 when it hasn't been declared with a value yet. Looks like a spelling error to me
 

FrostyCat

Redemption Seeker
You need to work on your basics and stop rushing.

First you need to understand the difference between the Create event and the Step event:
  • The Create event runs once when the instance is created, and is the place for setup actions.
  • The Step event repeats once every frame thereafter, and is the place for ongoing actions.
Setting opposite to a starting value is a setup action. So is freezing the animation by setting image_speed to 0. These two lines belong in the Create event:
GML:
opposite = 0;
image_speed = 0;
The rest of your code monitors opposite and global.drawbridge over time, those lines belong in the Step event. Although I think your code is supposed to be setting image_index, not sprite_index. And for the last time, learn to spell opposite properly already, the compiler is not going to check your spelling for you and forgive your careless typos.

Really, drop your project for now and start with a basic tutorial from this page. At the very least, learn what the different events do and how basic GML works. Use the Manual's Index tab to look up unfamiliar functions and variables, don't guess what they do.
 
G

gohkenytp

Guest
You need to work on your basics and stop rushing.

First you need to understand the difference between the Create event and the Step event:
  • The Create event runs once when the instance is created, and is the place for setup actions.
  • The Step event repeats once every frame thereafter, and is the place for ongoing actions.
Setting opposite to a starting value is a setup action. So is freezing the animation by setting image_speed to 0. These two lines belong in the Create event:
GML:
opposite = 0;
image_speed = 0;
The rest of your code monitors opposite and global.drawbridge over time, those lines belong in the Step event. Although I think your code is supposed to be setting image_index, not sprite_index. And for the last time, learn to spell opposite properly already, the compiler is not going to check your spelling for you and forgive your careless typos.

Really, drop your project for now and start with a basic tutorial from this page. At the very least, learn what the different events do and how basic GML works. Use the Manual's Index tab to look up unfamiliar functions and variables, don't guess what they do.
I know the variables, but I want you to take a look at this:
GML:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.opposite(100168, -2147483648) not set before reading it.
 at gml_Object_obj_drawbridge_CreateEvent_1 (line 2) - if opposite = 0
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 2)
This is me trying to get rid of that fatal error in obj_drawbridge (Draw-Bridges from the Super Mario Bros 3 World Map).
 

FrostyCat

Redemption Seeker
I know the variables, but I want you to take a look at this:
GML:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.opposite(100168, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 2) - if opposite = 0
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 2)
This is me trying to get rid of that fatal error in obj_drawbridge (Draw-Bridges from the Super Mario Bros 3 World Map).
I have taken a look at it, and you have not followed my instructions.
Setting opposite to a starting value is a setup action. So is freezing the animation by setting image_speed to 0. These two lines belong in the Create event:
GML:
opposite = 0;
image_speed = 0;
The rest of your code monitors opposite and global.drawbridge over time, those lines belong in the Step event.
Why are you still trying to check if opposite = 0 in the Create event, even though I told you to check in the Step event instead?

For the last time, separate your code into 2 events. The Create event should only be setting opposite and image_speed, nothing else. The Step event is where your ongoing if checks belong.
 

ophelius

Member
Looking at your original code above, you had
if opposite = 1
at the beginning.

But this new error message shows that you changed it because it now says:
if opposite = 0

We weren't saying change that line to
if opposite = 0
we were saying that before you have this line:
if opposite = 1
you need to first set the opposite variable to 0 BEFORE that line even happens.

But like FrostyCat is saying, you need to understand the difference between the Create event and Step event.
Set you opposite variable equal to 0 in your Create event, then move all that code into your Step event.

You should really look at the help file for basic understanding first, I highly recommend it.
 

Sabnock

Member
@gohkenytp

did you resolve this?

As others have said GMS can't read a variable in situations like below unless it has had a value assigned to it.

if (opposite == 0) {} // doesn't work if opposite has never been initialised. it is like me asking you to tell me how many dohickies are required to make a doobrywhatsit if you don't first know what a dohicky is.

same with

a = opposite // a can never = opposite if opposite doesn't exist because you haven't declared it first i.e. in the Create event or by some other code elsewhere.

it also doesn't parse text so if you use opposite = something to declare a variable and then try to read it with if (oposite == 0) {} GMS will not auto correct the spelling mistake and think that oposite is just another variable but in this case a none existent one.
 

Yal

🐧 *penguin noises*
GMC Elder
Variable obj_drawbridge.opposite(100168, -2147483648) not set before reading it.
Set the variable to a value before you try doing maths or branching off of it.


Also, = and == does different things in a lot of languages, and you really should be using == for comparisons - GM allowing = in if statements is deprecated.
 
G

gohkenytp

Guest
@gohkenytp

did you resolve this?

As others have said GMS can't read a variable in situations like below unless it has had a value assigned to it.

if (opposite == 0) {} // doesn't work if opposite has never been initialised. it is like me asking you to tell me how many dohickies are required to make a doobrywhatsit if you don't first know what a dohicky is.

same with

a = opposite // a can never = opposite if opposite doesn't exist because you haven't declared it first i.e. in the Create event or by some other code elsewhere.

it also doesn't parse text so if you use opposite = something to declare a variable and then try to read it with if (oposite == 0) {} GMS will not auto correct the spelling mistake and think that oposite is just another variable but in this case a none existent one.
I tried that but comes out as this:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.opposite(100171, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 2) - if (opposite == 1)
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 2)
 

TsukaYuriko

☄️
Forum Staff
Moderator
Open obj_drawbridge's Create event.

On line 1, at the leftmost possible position, paste this line:
GML:
opposite = 0;
 
G

gohkenytp

Guest
Set
GML:
opposite = true;
No "if"s

Compare
GML:
if(opposite == true){

}
Still doesn't work:
GML:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.opposite(100171, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 7) - if(opposite == true){
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 7)
And so does Tsuka's:
GML:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.opposite(100171, -2147483648) not set before reading it.
 at gml_Object_obj_drawbridge_CreateEvent_1 (line 7) - if opposite = 0{
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 7)
 

saffeine

Member
open obj_drawbridge, open the create event, go to the very first line and put opposite = true;.
don't edit anything else, don't add if( ), don't add an extra =, just set opposite to true.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Open obj_drawbridge's Create event.

On line 1, at the leftmost possible position, paste this line:
GML:
opposite = 0;
Did you follow this exactly as written? If yes, to prove it, post the code of the entire Create event of obj_drawbridge. If not, post the code of the entire Create event of obj_drawbridge anyway.
 
G

gohkenytp

Guest
I fixed it. But in the Mario world map when the drawbridge is open, Mario goes right through it. As it supposed to be like the drawbridges from the Mario 3 worldmap
 

saffeine

Member
I fixed it. But in the Mario world map when the drawbridge is open, Mario goes right through it. As it supposed to be like the drawbridges from the Mario 3 worldmap
it's probably because you put the rest of this code in the create event:
GML:
image_speed = 0
if opposite = 1
{
    if global.drawbridge = 1
    {
        solid = 0
        sprite_index = 0
    }
    else
    {
        sprite_index = 1
        solid = 1
    }
}
else
{
    sprite_index = global.drawbridge
    if global.drawbridge = 0
        solid = 0
    else
        solid = 1
}
move it to the step event or it will never update.

note: keep the opposite = true; in the create event or the exact same thing will happen. also if it needs to be false, set it to false.
 

Sabnock

Member
I tried that but comes out as this:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_drawbridge:

Variable obj_drawbridge.opposite(100171, -2147483648) not set before reading it.
at gml_Object_obj_drawbridge_CreateEvent_1 (line 2) - if (opposite == 1)
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_drawbridge_CreateEvent_1 (line 2)


This code does not set the variable "opposite" it merely reads it but as "opposite" hasn't been given an initial value it does not exisit and so can't be read.
GML:
image_speed = 0
if opposite = 1
{
if global.drawbridge = 1
{
solid = 0
sprite_index = 0
}
else
{
sprite_index = 1
solid = 1
}
}
else
{
sprite_index = global.drawbridge
if global.drawbridge = 0
solid = 0
else
solid = 1
}

In the create event for obj_drawbridge can you put the following code
GML:
opposite = 0; // or use true and false .
And let us know if the error continues or produces another error in your game please?

If you are not sure on how to do this then, as has been mentioned elsewhere in this thread, you should go back to basics and learn how objects, instances and the variables within them work.
 
Last edited:
I really think you are trying to run before you can walk. If you are having a hard time understanding that you need to set a variable before you access it, then you need to go over the basics more before trying to create a mario game (this is considered one of the "toughest" of the beginner game builds). Read through the manual in GMS, go through the tutorials in the GMS IDE (ALL of them), experiment in extremely limited situations; for instance, try to get the value of a variable to draw to the screen, try to get a player to move left and right, etc, WITHOUT just copying and pasting someone else's code. Typing in code without understanding it is like throwing random ingredients from a fridge across the room into a bowl and hoping you'll make cake batter. It's not going to turn out well.
 

saffeine

Member
I really think you are trying to run before you can walk. If you are having a hard time understanding that you need to set a variable before you access it, then you need to go over the basics more before trying to create a mario game (this is considered one of the "toughest" of the beginner game builds). Read through the manual in GMS, go through the tutorials in the GMS IDE (ALL of them), experiment in extremely limited situations; for instance, try to get the value of a variable to draw to the screen, try to get a player to move left and right, etc, WITHOUT just copying and pasting someone else's code. Typing in code without understanding it is like throwing random ingredients from a fridge across the room into a bowl and hoping you'll make cake batter. It's not going to turn out well.
i want to second this. regardless of whether or not you've managed to fix the issue by the end of this thread, you seemed to struggle to follow 90% of what was going on.
i'd urge you to aim for something simpler than a SMB3 clone as your first project, to understand what variables are, how they work, why you need to set them before you compare them, and what events execute code at what times.
ultimately you're free to do whatever you want, but you're signing yourself up for a world of pain and at a rate like this, people will feel less inclined to help you in the future if you don't know what their advice means.
either way, i wish you the best and hope you continue to work at it. you'll get there one day if you set your mind to it.
 

saffeine

Member
Sheesh. If I can't do it, then somebody make it for me for Hello's Mario Engine. I don't have anything to hide.
nobody's telling you that you can't, we're just telling you that it's ill-advised. if you genuinely want to learn how to make games, you need to start with the basics as we all did.
if not, then feel free to move at your own pace, but be ready to face all of the blockades that you could easily avoid in the future.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Sheesh. If I can't do it, then somebody make it for me for Hello's Mario Engine. I don't have anything to hide.
Please don't get frustrated with the people that are trying very hard to help you, and also don't ask them to make stuff for you. We're here to help you, but that doesn't mean we're here as little code minions to churn out scripts and code when you require it. If you are serious about making games, then you have to realise that sometimes things will just not work, and then you have to strive to learn how to make them work!

So, the best help you can get from this forum is what we've been telling you... you need to declare all variables to a value before you can you use them, and when you use them you need to ensure you are using them in the appropriate place. In this case you'd have a CREATE EVENT with something like:
GML:
opposite = 0; // This declares the variable to the object, making it ready to be used
Then in your STEP event you'd check this variable:
GML:
// The variable is declared and has a value so we can use it now
if (opposite == 1)
{
// do something
}
else
{
// do something else
}
If you are having trouble grasping this concept, don't stress out or get upset!!! We all have problems learning stuff sometimes, and what seems obvious to some seems like greek to others. I really think though that if this is giving you problems, you should put aside the project you are working on right now, and instead dedicate a couple of days to doing the tutorials that come with GameMaker (you can get them from the Start Page when you launch GameMaker Studio 2). Once you've done them, come back to your main project and I'm sure you'll understand the issues you've been having and be able to fix them.

All the best!
 
G

gohkenytp

Guest
Let me explain: When the drawbridge is closed, Mario on the world map goes through. When the drawbridge is open, Mario on the world map can't go through. Which is what I'm trying to do.
 
G

gohkenytp

Guest
Ok
Code:
image_speed = 0
if (opposite == true)
{
if global.drawbridge = 1
{
solid = 0
image_index = 0
}
else
{
image_index = 1
solid = 1
}
}
else
{
image_index = global.drawbridge
if global.drawbridge = 0
solid = 0
else
solid = 1
}
 

KPJ

Member
Could you also post the code where you declare the "opposite" variable? Also could you specify which event you declared the "opposite" variable, and which event the code you provided above is in?

I would also suggest that when you are posting your code, use the provided code tags, labeled as </> in the post editor, as it makes it easier to comprehend.
 
G

gohkenytp

Guest
Alright:
image_speed = 0
if opposite = 1
{
if global.drawbridge = 1
{
solid = 0
sprite_index = 0
}
else
{
sprite_index = 1
solid = 1
}
}
else
{
sprite_index = global.drawbridge
if global.drawbridge = 0
solid = 0
else
solid = 1
}
 

KPJ

Member
Looking at the code, it looks like the exact same thing you just posted. It doesn't really answer my questions, maybe you misunderstood?

My questions were to post the code in which you declared the"opposite" variable, and specify which events you have your code in.

Again, it would be helpful if you posted your code in the </> tags, it makes it easier to read👍
 
Status
Not open for further replies.
Top