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

SOLVED Simple script bug, don't know how to fix

I

iAnzenGenki

Guest
Just trying to follow along with Mr. Spalding's tutorial on calling scripts and ran into errors on lines 1 and 5 (this is in the script I'm trying to use):

GML:
//Update Sprite
var _cardinalDirection = round(direction/90);
var _totalFrames = sprite_get_number(sprite_index) / 4;
image_index = localFrame + (_cardinalDirection * _totalFrames);
localFrame += sprite_get_speed(sprite_index) / FRAME_RATE;

if (localFrame >= _totalFrames)
{
    animationEnd = true;
    localFrame -= _totalFrames;
} else animationEnd = false

I know he made this tut on the earlier version and some changes were made to calling scripts with function -enter whatever script name here-
I did follow back to what changes were made and I'm still baffled but this is probably a very easy fix. I know when you first create a script it has that function (script name) with looping brackets...I just deleted them because they weren't what he was coding. My code is exactly like his and no errors popped up on his screen.

EDIT: I accidentally used an equal sign in the Macro script...which somehow pulls the errors into the script I'm calling the value from...odd but fixed.
 
Last edited by a moderator:

FoxyOfJungle

Kazan Games
Are you referring to that?

GML:
function testfunction()
{
    //Update Sprite
    var _cardinalDirection = round(direction/90);
    var _totalFrames = sprite_get_number(sprite_index) / 4;
    image_index = localFrame + (_cardinalDirection * _totalFrames);

    localFrame += sprite_get_speed(sprite_index) / FRAME_RATE;

    if (localFrame >= _totalFrames)
    {
    animationEnd = true
    localFrame -= _totalFrames;
    } else animationEnd = false
}
You call "testfunction()".
 
I

iAnzenGenki

Guest
@FoxyOfJungle No, that kinda made things worse, popped up 2 more bad lines 😬

The errors I got were:
PlayerAnimateSprite at line 1, 19 : unexpected syntax error
PlayerAnimateSprite at line 5, 48 : unexpected unary operator =

EDIT: Never mind, I did need that. Thanks Foxy 😁
 
Last edited by a moderator:

FoxyOfJungle

Kazan Games
@FoxyOfJungle No, that kinda made things worse, popped up 2 more bad lines 😬

The errors I got were:
PlayerAnimateSprite at line 1, 19 : unexpected syntax error
PlayerAnimateSprite at line 5, 48 : unexpected unary operator =

EDIT: Never mind, I did need that. Thanks Foxy 😁
Sorry, I didn't quite understand what your question was 😅
 
Top