turf
Ground
icon_state="1";
density=1;
mob/var
jumping=0;
mob
proc
Gravity() {
if(src.jumping==2) {
var/oldDir=src.dir;
step2(SOUTH);
src.dir=oldDir;
for(var/turf/Ground/G in view(2)) {
if(G.x==src.x&&G.y==src.y-1&&src.step_y==0) {
src.jumping=0;
src.icon_state="";
}
}
}
else if(src.jumping==0) {
world << "They are not jumping"
for(var/turf/Ground/Gr in view(2)) {
world << "Check"
if(!Gr) { src.jumping=2; world << "Now They Are Jumping" }
if(Gr.y!=src.y-1&&Gr.x==src.x) { src.jumping=2; world << "Now They Are Jumping[src.jumping]" }
}
}
sleep(0.5);
Gravity();
}
step2(var/direction) {
step(src,direction);
step(src,direction);
}
Whenever the player's "jumping" var is set to 2 the code has no problem entering the for() loop to find turf/Ground/G in view, but for some reason it's not doing the same for my else if block immediately after that.
Whenever I run the game, my output consistently posts "They are not jumping", but it doesn't mention "Check" or "Now They Are Jumping[src.jumping]" even when I remove the statement that claims they are not jumping.
An even stranger thing that is happening is that whenever the player is positioned directly above an instance of turf/Ground the code outputs Now They Are Jumping0 instead of outputting Now They Are Jumping2. This means that the code is not setting src.jumping to 2, but still outputting "Now They Are Jumping" message at the same time; which is weird because the code should set src.jumping=2 right before that output message.
Any help is appreciated, thank you for taking the time to read my code and the summary of what happened when said code was executed!