• 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!

Please help, no able to create scripts

K

KakuniProject

Guest
Hello everyone, I'm quite new to game maker and into programming. I recently started a game and I'm on the first steps creating the collisions and movements,
the collisions it was working fine when I inserted into step/Object, however now I tried to add into a script .
I simply copied and pasted my code into my script, and did not work for some reason it is sayin is a problem on line 3. I tried everything and couldn't fix the problem.
I will attach a screenshot of my code that I'm trying to add on script, also I will add my code below. I would highly appreciate if someone help me and I am deeply sorry if I didn't post this question in the right question.
Thank you very much.


My collision code below;

//Calculate Collision Horizontal

if(place_meeting(x+hsp,y,OinvisibleGround))

{
while(!place_meeting(x+sign(hsp),y,OinvisibleGround))
{
x = x + sign(hsp);
}
hsp = 0
}
x = x + hsp;

//Calculate Collision Vertical

if(place_meeting (x , y + vsp ,OinvisibleGround))

{
while ( !place_meeting (x, y + sign (vsp) ,OinvisibleGround))
{
y = y + sign(vsp);
}
vsp = 0;
}

y = y + vsp;

//Jumping Movement

if (place_meeting(x,y+1,OinvisibleGround)) // To recognise if standing on ground:
{
jumps=jumps_max;
}

if (key_jump) && (jumps > 0) //If you jump and jump variable is = to more than 0, Jump and subtract -1 from jumps
{
jumps -= 1;
vsp = jump_height;
}


The error is ;

ERROR in
action number 1
of Create Event
for object <undefined>:

Variable <unknown_object>.y(1, -2147483648) not set before reading it.
at gml_GlobalScript_movement_calculation (line 3) - if(place_meeting(x+hsp,y,OinvisibleGround))
############################################################################################
gml_GlobalScript_movement_calculation (line 3)
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Hello everyone, I'm quite new to game maker and into programming. I recently started a game and I'm on the first steps creating the collisions and movements,
the collisions it was working fine when I inserted into step/Object, however now I tried to add into a script .
I simply copied and pasted my code into my script, and did not work for some reason it is sayin is a problem on line 3. I tried everything and couldn't fix the problem.
I will attach a screenshot of my code that I'm trying to add on script, also I will add my code below. I would highly appreciate if someone help me and I am deeply sorry if I didn't post this question in the right question.
Thank you very much.


My collision code below;

//Calculate Collision Horizontal

if(place_meeting(x+hsp,y,OinvisibleGround))

{
while(!place_meeting(x+sign(hsp),y,OinvisibleGround))
{
x = x + sign(hsp);
}
hsp = 0
}
x = x + hsp;

//Calculate Collision Vertical

if(place_meeting (x , y + vsp ,OinvisibleGround))

{
while ( !place_meeting (x, y + sign (vsp) ,OinvisibleGround))
{
y = y + sign(vsp);
}
vsp = 0;
}

y = y + vsp;

//Jumping Movement

if (place_meeting(x,y+1,OinvisibleGround)) // To recognise if standing on ground:
{
jumps=jumps_max;
}

if (key_jump) && (jumps > 0) //If you jump and jump variable is = to more than 0, Jump and subtract -1 from jumps
{
jumps -= 1;
vsp = jump_height;
}


The error is ;

ERROR in
action number 1
of Create Event
for object <undefined>:

Variable <unknown_object>.y(1, -2147483648) not set before reading it.
at gml_GlobalScript_movement_calculation (line 3) - if(place_meeting(x+hsp,y,OinvisibleGround))
############################################################################################
gml_GlobalScript_movement_calculation (line 3)
IF you really want it all to be a script, wrap it all up in

GML:
function nameofscript() {

//all your codehere


}
 

rytan451

Member
Hi, for future reference, please wrap your code in code tags. They look like this:

[code=gml]
function foo() {
show_debug_message("bar");
}
[/code]

And they make your code look like this:

GML:
function foo() {
  show_debug_message("bar");
}
Reading code not formatted like code is annoying, which is not something you want to do when asking for help.
 
Top