Compile eorror wtf

A

AtLantiSs

Guest
ERROR!!! :: ############################################################################################
FATAL ERROR in
action number 1
of Step Eventobj_MudHopper
for object obj_hovertank_shot:


Variable obj_hovertank_shot.encounter(100137, -2147483648) not set before reading it.
at gml_Object_obj_hovertank_shot_CollisionEvent_47_1 (line 37) - target = encounter;
############################################################################################

Compile finished: 2:50:47 PM


What in Satans ******* does that mean?



in the collision event with a bullet & enemy basic I have this


if team =1
{
{
with(other)
{

scr_blood();

alarm[2] += random(30)+irandom_range(0,5)
HitBy = "Ranger"
}
if instance_position(x,y,obj_MudHopper)
{
if !irandom(3)sound_play(snd_mudhopper_hit)
if ChallengeMode = 1 {hp -= 5}
if ChallengeMode = 0 {hp -= 1}
target = encounter;
see = 1;}

}
}

target = nothing
encounter = instance nearest enemy basic

all enemies t=have the above variables but this BS says the bullet sdoesmt have it set -____-_--

Why do I get the error above if the code is saying that if the bullet hits the enemy, if it's a mudhopper, remove health from it.

Talking about some stupid ass variabble wasn't set -_____-
 

MusNik

Member
Well, check this "encounter" variable, where did you init and set it, what can I say.

P.S. Please, use code tag when posting code.
 
Last edited:
D

DevNorway

Guest
Make sure just in case any error would pop up later, set target = 0 and encounter = 0 or whatever value you want it to be in the create event.
 
A

AtLantiSs

Guest
I'm trying to make the enemies target = encounter but instead it makes the bullet do that when I want the enemy to change the value of target for itself
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
First of all, calm down. Using bad language and getting angry won't help you and it certainly doesn't help us to help you... ;)

Now, second, let's analyse that message:

- "Variable obj_hovertank_shot.encounter(100137, -2147483648) not set before reading it."

Okay, so the variable "encounter" in the object "obj_hovertamk_shot" is not set before it is being read... That should be fairly obvious, no? Let's look at the next line:

- "at gml_Object_obj_hovertank_shot_CollisionEvent_47_1 (line 37) - target = encounter;"

Ah, so this tells us exactly where the issue is. Line 37 you have "target = encounter". So what is wrong here? You haven't set the variable encounter... You actually say what the problem is here:

all enemies t=have the above variables but this BS says the bullet doesn't have it set -____-_--
The enemies have the variable but the bullet doesn't... so set this variable in the CREATE EVENT of the bullet. However you have then said:

I'm trying to make the enemies target = encounter but instead it makes the bullet do that when I want the enemy to change the value of target for itself
This implies that you need to set this in the "with(other)" which currently you are not doing. I think you need to rethink the whole code logic and also check the code scope and variable scope to make sure you are addressing and using the correct variables in the correct objects.
 
Last edited:
  • Like
Reactions: Roa
Top