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

Data Structures

C

CRob1974

Guest
Hi, I am trying to create a ds_list and have been trying to create a test program to see if I have got it right but it doesnt seem to work. I understand the concept but dont think I have structured the program correctly. The code is written in an invisible controller object.

Here is my code, any help would be appreciated. Thank you.

CREATE
list = ds_list_create();
listmax = 10;

STEP
if (keyboard_check_pressed(vk_space))
{
if (ds_list_size(list) < listmax)
{
ds_list_add(list,"Item");
}

if (ds_list_size(list) > listmax)
{
show_message("Max Reached")
}
}
 

NeoShade

Member
Try => rather than just >

Your if loop only puts 10 items in the list, so there will never be 11, so the message will never show.

Otherwise, everything looks correct to me.
 
C

CRob1974

Guest
NEOSHADE: Thank you for the reply, I got an error with => so I used >= instead and it worked fine.
 

NazGhuL

NazTaiL
Code:
if (keyboard_check_pressed(vk_space))
{
    if (ds_list_size(list) < listmax)
    {
    ds_list_add(list,"Item");
    }
    else
    {
    show_message("Max Reached")
    }
}
 
C

CRob1974

Guest
Naz: Nice, Im working on a Buy / Sell shop program and this should help. Thank you.
 
Top