M0ros
M0ros

Reputation: 11

function parameters not being registered in the code in GML

I'm working on a game and I have made some code to switch between rooms. This code is still not nearly finished looking at what I will be adding in the future, but one thing that I will definitely need is a function that makes the player go to the next room under the right circumstances as well as getting them to the right coördinates. However, I have a constant error message that says that my function doesn't take more than 0 arguments and I can't seem to fix it.

function roomchange(dir)
{
    if (x < 16)
    {
        room_goto(dir);
        x = room_width - 16; 
    }
    else if (y < 16)
    {
        room_goto(dir);
        y = room_height - 16;
    }
    else if (x > room_width - 16)
    {
        room_goto(dir);
        x = 16;
    }
    else if (y > room_height - 16)
    {
        room_goto(dir);
        y = 16;
    }
    prev_room = current_room;
    current_room = next_room;
}

if place_meeting(x, y, obj_ndoor1)
{
    next_room += 1;
    roomchange(next_room);
}
else if place_meeting(x, y, obj_ndoor2)
{
    next_room += 2;
    roomchange(next_room);
}
else if place_meeting(x, y, obj_ndoor3)
{
    next_room += 3;
    roomchange(next_room);
}
else if place_meeting(x, y, obj_pdoor)
{
    roomchange(prev_room);
}

I don't know if the code is a little unoptimized or illogical but this is my first project on GameMaker. That's why I want to understand what the issue is rather than completely changing the code without ever finding out what is wrong.

I've tried a couple fo things such as renaming the parameter and moving the update locations of the variable next_room as well as moving the function. I figured that maybe if I moved the function somewhere else in the code it would correctly read it.

Upvotes: 1

Views: 27

Answers (0)

Related Questions