Game Maker 7 GML array length

909 views Asked by At

I am working in Game Maker 7 using GML in order to create a Main Menu for my game. I have looked for a while now trying to find out what the code is to use the length of an array however I cannot find it. What I have so far is:

var move = 0;
move -= max(keyboard_check_pressed(vk_up),(keyboard_check_pressed(ord("W")),0);
move += max(keyboard_check_pressed(vk_down),(keyboard_check_pressed(ord("S")),0);

if (move != 0)
{
    mpos += move;
    if (mpos <0) mpos = array_length_1d(menu) - 1;
    if (mpos > array_length_1d(menu) - 1) mpos = 0;
}

var push;
push = max(keyboard_check_released(vl_enter),keyboard_check_released(vk_shift),keyboard_check_released(vk_space), 0);
if (push == 1) Scr_Menu();

This is meant to cycle through the array and make sure that the menu arrow doesn't go where a option is. The error I am receiving is:

FATAL ERROR in action number 1 of Step Event for object Obj_Menu:

COMPILATION ERROR in code action Error in code at line 8: if (mpos <0) mpos = array_length_1d(menu) - 1;

at position 26: Unknown function or script: array_length_1d

1

There are 1 answers

1
Ali Bahrami On

You should write array_length_1d instead of array_get_length_1d. "get" is unnecessary.