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

Legacy GM [SOLVED] If a ds_list_find_index() doesn't find a value...

M

Mihaugoku

Guest
I might just be dumb again, but i'm having trouble with reading values from a ds_list.

Currently experimenting with a simple inventory system i thought of, and the part that i can't figure out is how the ds_list_find_index() function handles finding no free space when "picking up" an item.

The code in "scr_pickup" is very simple, but sadly the "var val2" part doesn't work:
Code:
for(i=0; i<10; i++) {
    var val = ds_list_find_value(global.inv,i)
    if val = 0 {
        ds_list_set(global.inv,i,global.item_list)
        instance_destroy()
        break;
    }
   
    var val2 = ds_list_find_index(global.inv,0)
    if val2 = undefined {
        obj_blu.inv_full = true
    }
}
Also tried using:
Code:
    if is_undefined(val2) {
What i'm trying to do is make a message appear like "Inventory full!" when the player has all slots taken up.
What i wanna know is how to make the ds_list_find_index() read a "no value" situation.

EDIT//
Waited for an hour, managed to find out the answer on my own.......
 
Last edited:
Top